i did add OneSignal based on the documentation in my application.
Everything works for me.
However, I can't send notifications to some devices because it says: Google Play Services Library Error (image included)
What I've already tried:
I created a new project in OneSignal (new app id)
the AndroidManifest.xml file contains:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I don't know what to do now.... :(
Google Play Services Library Error
UPDATE:
only appears on some devices, on first start-up.
Error message:
E / OneSignal: Error Getting FCM Tokenjava.io.IOException: AUTHENTICATION_FAILED
If you reopen the application, the error will disappear.
Try removing and recompiling the application
Related
so I have an existing app that has been on the app store for quite some time, as of 3 days ago I was getting more support enquiries saying my app could not connect to my service.
Now it has finally happened to me on my Android devices - everything works perfectly for iOS, and perfectly for Android on Emulator - but nothing in the real world.
I have looked as far as I can by step-debugging with Cordova and it passes the whitelist test fine. My very first XHR request works fine, but subsequent ones always fail until I completely close the app and re-open.
I am using cordova-plugin-whitelist#1.3.4 - I have also tried cordova-plugin-whitelist#1.0.0
My Content-Security-Policy looks like this
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' gap:; img-src http://*.my-site.com.au https://*.my-site.com.au https://*.my-site.com http://*.my-site.com https://*.googleusercontent.com http://*.googleapis.com https://google.com https://*.google.com https://*.googleapis.com https://*.gstatic.com 'self' data:; style-src http://*.googleapis.com https://*.googleapis.com 'self' 'unsafe-inline'; script-src 'self' https://*.googleapis.com http://*.googleapis.com http://maps.google.com http://*.gstatic.com https://*.gstatic.com https://maps.google.com 'unsafe-inline' 'unsafe-eval'">
My Cordova config has
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
I have tried adding/removing/replacing the above/every combination with <access origin="*" /> but no luck.
My XHR response always looks like the following
xhr.responseUrl = "http://my-site.com/?d=12343902i49"
xhr.status = 0
xhr.responseText = ""
I have step-debugged the XHR request as far as I could have in the Cordova Plugin, by step debugging out of the Whitelist.java but everything returns fine and it makes it successfully to the line
// If we don't need to special-case the request, let the browser load it.
return null;
of function
WebResourceResponse shouldInterceptRequest(WebView view, String url)
in org.apache.cordova.engine.SystemWebViewClient.java
My Android Manifest has the following
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
I am using Cordova#8.0.0, Cordova platform Android#8.0.0
I've spent several hours trying to dig deeper, what am I missing here? Any help would be greatly appreciated!
As the problem disappears if you lower the targetSDK, it's probably the usesCleartextTraffic mentioned by Nidhin Josehp. It only affects Android 8 or newer devices when targeting SDK 28 or greater.
Instead of manually editing the AndroidManifest.xml as he suggest (you should never manually edit it in Cordova apps) you can add this to the config.xml
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
You might need to change your widget tag in config.xml to look something like this:
<widget id="com.your.app.id" version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
(The addition is the xmlns:android="http://schemas.android.com/apk/res/android")
Try adding android:usesCleartextTraffic="true" to the <application> in the AndroidManifest.xml or as below using config.xml
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
android:usesCleartextTraffic Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default
value for apps that target API level 27 or lower is "true". Apps that
target API level 28 or higher default to "false". More info
Cleartext is any transmitted or stored information that is not
encrypted or meant to be encrypted. When an app communicates with
servers using a cleartext network traffic, such as HTTP, it could
raise a risk of eavesdropping and tampering of content which is why in latest Android devices, it's set to false by default.
I'm going to jump I swear.
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" />
Changed targetSdkVersion to 26 from 28. Worked. But this is going to be a nightmare.
Edit: Problem has come back but only for Samsung Galaxy Tablets. I can't replicate this behaviour anywhere else.
Edit2: Things are...fine again?
Your issues sounds quite similar to what is discussed in Cordova doesn't send origin on request in some Android devices, which refers to a CORS-related issue caused by a bug introduced in Chrome 76 (WebViews based on the same version of WebKit are affected too). Chrome 76 started to be rolled out beginning of August 2019. The problem often disappears if the affected app is restarted but returns randomly.
The corresponding ticket is https://bugs.chromium.org/p/chromium/issues/detail?id=991107. According to the ticket, the problem is fixed in Chrome 76.0.3809.111, which is being rolled out these days.
On your emulator you probably have an older version of Chrome, which might be the reason why the problem doesn't show up there. If you compare affected and unaffected devices and see, that only devices running Chrome in versions >= 76.0 and < 76.0.3809.111 show the symptoms, you probably found the cause of the problem.
If this is the case, you have at least these options:
Wait util the fixed version of Chrome has been rolled out (which might the case already for many affected phones).
If you're in control of the server, you could add the file:// origin to the list of allowed origins there, which is what we did. You have to think about the security implications carefully though.
Btw, after restarting the app, the issue most often disappeared, which makes it hard to debug. We found out, that it can be reproduced by uninstalling and reinstalling the affected app.
I have reviewed all similar questions regarding Google Maps authorization failure but it did not help.
Google Maps Api v2 is enabled and correct.
Android Keys for Debug and Release builds are correct and their corresponding validation Package Names and Fingerprints are correct.
Now, the first strange thing is that Google Maps had been working perfectly for 1 and a half years and we did not register any errors until 23 May 2016.
We did not change anything in Google Dev Console or in Application that would be a threat to Google Maps functionality.
The second strange thing is that this error only occurs on Release builds and Debug builds are working fine. With this in mind I tried to generate another Android Key for maps (without package/fingerprint validation) but it did not help.
Android Manifest contains these permissions:
com.google.android.providers.gsf.permission.READ_GSERVICES
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
INTERNET
ACCESS_NETWORK_STATE
WRITE_EXTERNAL_STORAGE
We also use:
<uses-feature
android:glEsVersion="0x00020000"
android:required="false" />
Play Services Maps API:
compile 'com.google.android.gms:play-services-maps:6.5.87'
Yes, this API is quite old but updating it to 8.4.0 did not help either.
Google Maps authorization failure we're getting:
E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
07-27 14:52:37.551 25002-25035/com.package.name E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: ******************************
Android Application (<cert_fingerprint>;<package_name>): finger:print;com.package.name
If someone had any ideas on where or why such a problem could suddenly happen I would be more than happy with any help.
Thank you.
Try to use updated google map api
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
and check whether you had used these permission in app
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.example.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
and used these meta tag within application
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/application_id" />
// as unauthorized occurs just because of invalid app id which created on google developer console
I'm getting the following crash, but this only occurs on some Samsung devices (not all, we develop/test on Samsung devices)
Crash log:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.bluetooth.IBluetooth$Stub$Proxy.isEnabled(IBluetooth.java:1156)
at android.bluetooth.BluetoothAdapter.isEnabled(BluetoothAdapter.java:697)
at org.altbeacon.beacon.service.scanner.CycledLeScanner.finishScanCycle(CycledLeScanner.java:245)
at org.altbeacon.beacon.service.scanner.CycledLeScanner.scheduleScanCycleStop(CycledLeScanner.java:234)
at org.altbeacon.beacon.service.scanner.CycledLeScanner$1.run(CycledLeScanner.java:230)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5972)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Here's my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.myapp" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!--
The following two permissions are not required to use Google Maps Android API v2,
but are recommended. We also require them for location updates.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission
android:name=".permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name=".permission.C2D_MESSAGE" />
<application
android:name=".myapp"
android:allowBackup="true"
android:icon="#drawable/appicon"
android:label="#string/app_name"
android:logo="#drawable/action_bar_pinwheel_back"
android:theme="#style/AppTheme" >
<activity
android:name=".activities.VerifyPinActivity"
android:label="#string/title_activity_verify_pin"
android:screenOrientation="portrait"
android:theme="#style/NoActionBarDark"
android:windowSoftInputMode="stateVisible|adjustPan" >
</activity>
...(more activities here removed)
</application>
</manifest>
I really have no idea why it only occurs on a few devices; my initial guess is it has something to do with Samsung KNOX, and the (few) users that are crashing are KNOX users with a phone policy to disable Bluetooth.
Has anyone else run into this? Or does anyone have any idea what this might be?
If you are sure the users met this problems only on Samsung KNOX,the following answer maybe will help you.
Thinking step by step is the way to solve your problem.
1.This only occurs on some Samsung devices.
So, it has nothing to do with your code,also the permission.There is
something wrong with the Samsung devices.
2.Check the crash log:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.
According to the experience,if you have met the log like "Neither user
**** nor current process has *** permission.",this means that your app doesn't have the permission to do something in the system.This occurs
often on that you do something need the system level permission.
If you are installed as system level app together with customized Android ROM,or you signed your app with the platform.x509.pem and platform.pk8 file of the customized Android ROM,and then you can have the permission.
Now check what is Samsung KNOX:
Samsung Knox (stylized Samsung KNOX) is an enterprise mobile security solution.
Bluetooth is one kind of data transmission way to the other's
device.This will cause the security problem.
Check the offical website:
https://www.samsungknox.com
Search the key words 'Bluetooth',and we found this:
https://www.samsungknox.com/en/faq/are-bluetooth-bluetooth-low-energy-and-nfc-available-inside-knox-container
KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container.
KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. If the device is connected to a peripheral (e.g. headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. Apps inside the KNOX container can't initiate a Bluetooth connection.
1.If your users are using KNOX 2.3 or below,and they can update their OS of device to KNOX 2.4+.tell your users who use Samsung
KNOX update their OS of device.
2.If your users are using KNOX 2.3 or below,and they can't update their OS of device to KNOX 2.4+.your app will not work under this
situation,the problem is not the problem,what you can do is only tell
uses that:the OS of your device doesn't support Bluetooth,so it's not
working.
3.If the above will not help you, you can contact with Samsung KNOX Official
Another tip:
To improve your user experience of your app, you need to prevent your app to be crashed.
Crashed is the worst user experience.
If you can not solve the problem,you can do this:
try{
You code related with Bluetooth.
}catch (Exception e)
{
}
Remember:The offical always helps you to solve the problems better!
You can look here. I'd guess this is your problem.
Are Bluetooth, Bluetooth Low Energy, and NFC available inside the KNOX container?
KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container.
KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. If the device is connected to a peripheral (e.g. headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. Apps inside the KNOX container can't initiate a Bluetooth connection.
I never had any hands-on experience with this, but I hope this helps.
try to add below to your manifest
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
From SDK 23 onward you need to check the permission for bluetooth in case required.
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (mContext.checkSelfPermission(Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_GRANTED) {
//TODO - Do the work
}
}
From KNOX Premium v1.1 onwards, Samsung no longer needs to sign third-party app (APK) files so that they can run inside KNOX containers. Instead, the appropriate permissions are granted at runtime, after an app activates its ELM and KLM licenses successfully. for more info see this
I'm trying to provide a Facebook Like button in my Android app and am having problems. I think that I have everything set up properly:
I'm calling FacebookSdk.sdkInitialize(getApplicationContext());
I've added a LikeView into my activity
I've created an app id using the appropriate key hashes
I've added the following into the manifest inside the application tag:
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProvider000000000099893"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
Where 000000000099893 is my application id (I've zeroed out most of it)
My app is crashing in Facebook's Utility.java class on the line:
FetchedAppSettings settings = fetchedAppSettings.get(applicationId);
Actually it crashes within the HashMap code with a null pointer
This leads me to believe that something is going wrong with my application id. What else should I be looking at?
Okay, after going through all of the code in the SDK and some of the samples I finally figured out what was going on. It seems that I need to add
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
<meta-data android:name="com.facebook.sdk.ApplicationName"
android:value="#string/facebook_app_name" />
into the manifest.
I just downloaded the SDK today - it says that the version is 4.2.0 but the instructions on the Facebook site do not mention these manifest changes.
Disappointed.
I am making a game with in-app purchasing for extra levels. I have implemented all of the necessary code and the test purchases work perfectly. However when I go to add the products to my (unpublished) app I get the following message on the android developer dashboard:
"New in-app products cannot be added because the current application version does not use the BILLING permission."
These are the permissions I have:
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.com.android.vending.BILLING" />
<uses-permission android:name="android.permission.BILLING" />
So I can't understand why I am getting this message. Any help would be greatly appreciated, I am trying to release the game this weekend and this is my last barrier.
Thanks in advance, and rest assured I WILL accept an answer, I know people on here get worried about that sometimes.
The problem is with the permission. Use
<uses-permission android:name="com.android.vending.BILLING" />
It looks like your app gets all the permissions it needs. My advice is to make sure that the uploaded version of the app is the current version, and also that you are logged in using your Google Checkout Merchant account (this is different from a regular Google or Google Checkout account) as referenced By the docs. Hope this helps!