Closed testaccnt0435 closed 6 years ago
@testaccnt0435 logs please.
me same problem too, in lower api some device can ,some cannot but in native app is no problem, this is cordova problem
@aihosting No, it is not a cordova problem it is an Android problem. Older versions of Android use GCM while the latest version of this plugin uses FCM. Some older Android's may not have the necessary play services version in order to receive push. Can't tell give you a better answer than that without logs of the problem.
@macdonst I'm sorry, I'm a newbie for phonegap app. I'm building the application using adobe phonegap build. How can I take log from it?
Hi @macdonst, I have tried this code in my app and I get that "receivedEvent error :PushNotification is not defined"
try {
alert('test');
var push = PushNotification.init({ "android": {"senderID": "XXXXXXXXXXX"}});
alert('test1');
push.on('registration', function(data) {
alert(data.registrationId);
document.getElementById("gcm_id").innerHTML = data.registrationId;
});
push.on('notification', function(data) {
alert(data.title+" Message: " +data.message);
});
push.on('error', function(e) {
alert(e.message);
});
}
catch(err) {
alert("receivedEvent error : " + err);
}
I receive the registrationID in devices 6.0 and above, but not on lower version android device.
@testaccnt0435 you can get logs from your device by doing adb logcat | grep Push
which will use the Android Device Bridge to communicate with your phone and get the logs.
If you are having issues on PGB not have PushNotification defined then you probably don't have the necessary version of cordova-android in your project to support the plugin.
I started getting crashes on android < 5.0, not sure if this is the same issue as @testaccnt0435 and @aihosting. I fixed this by upgrading the plugin to 2.1.0, but now I can't build at all. This is the error I get while building:
Error: /Users/Jesper/ttt/cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/Jesper/ttt/cordova/platforms/android/src/com/adobe/phonegap/push/FCMService.java:388: error: constructor Builder in class Builder cannot be applied to given types;
mBuilder = new NotificationCompat.Builder(context, channelID);
^
required: Context
found: Context,String
reason: actual and formal argument lists differ in length
/Users/Jesper/ttt/cordova/platforms/android/src/com/adobe/phonegap/push/FCMService.java:398: error: constructor Builder in class Builder cannot be applied to given types;
mBuilder = new NotificationCompat.Builder(context, channelID);
^
required: Context
found: Context,String
reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/Jesper/ttt/cordova/platforms/android/src/com/adobe/phonegap/push/PushPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
@jespertheend try upgrading your version of the Android Support Library and building again.
Thanks, that worked! I thought I had updated all the google play packages but apparently I was missing one that was hidden behind a 'show package details' checkbox.
However, I'm still getting crashes on 4.4 and lower, the same as the ones I had with the previous version:
I/ActivityThread( 4142): Pub com.jespertheend.tix.tax.firebaseinitprovider: com.google.firebase.provider.FirebaseInitProvider
D/ ( 1581): HostConnection::get() New Host Connection established 0xb7fc2128, tid 1698
D/AndroidRuntime( 4142): Shutting down VM
W/dalvikvm( 4142): threadid=1: thread exiting with uncaught exception (group=0xae654228)
E/AndroidRuntime( 4142): FATAL EXCEPTION: main
E/AndroidRuntime( 4142): java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
E/AndroidRuntime( 4142): at android.app.ActivityThread.installProvider(ActivityThread.java:4563)
E/AndroidRuntime( 4142): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190)
E/AndroidRuntime( 4142): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132)
E/AndroidRuntime( 4142): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
E/AndroidRuntime( 4142): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
E/AndroidRuntime( 4142): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4142): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4142): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 4142): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4142): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4142): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 4142): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 4142): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 4142): Caused by: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
E/AndroidRuntime( 4142): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 4142): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 4142): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 4142): at android.app.ActivityThread.installProvider(ActivityThread.java:4548)
E/AndroidRuntime( 4142): ... 12 more
I'm using cordova 7.1.0, cordova-android 6.4.0 and these plugins:
cordova-android-support-gradle-release 1.1.5 "cordova-android-support-gradle-release"
cordova-open-native-settings 1.4.1 "Native settings"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-headercolor 1.0 "HeaderColor"
cordova-plugin-splashscreen 4.1.0 "Splashscreen"
cordova-plugin-taptic-engine 2.1.0 "Taptic Engine"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-wkwebview-engine 1.1.4 "Cordova WKWebView Engine"
cordova-plugin-wkwebviewxhrfix 0.1.0 "WKWebView XHR Fix"
cordova-plugin-x-socialsharing 5.2.1 "SocialSharing"
cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"
es6-promise-plugin 4.1.0 "Promise"
phonegap-plugin-push 2.0.0 "PushPlugin"
Hmm, my bad. This crash log is still from when I was using 2.0.0. 2.1.0 is actually still giving the build error I posted earlier, I'll just try to check as many boxes as possible in the SDK manager because I never really know which one I need.
I can't seem to get it to work. I've tried installing several SDK build tools versions and SDKs but none of them seem to do the job. Any specific checkbox I need to have checked in the SDK manager?
@jespertheend did you make sure Google Play is up to date on our 4.4 device?
@macdonst everything in the sdk manager is up to date. I'm not sure if I missed anything, this is what it looks like right now. By the way, I'm talking about my first comment, this is happening to every version of android, not just 4.4 and older. My other comment was a crash from version 2.0.0 of this plugin. This is no longer an issue. At least I assume it's not but I'm unable to test.
@jespertheend if you can't build because of those errors it is because you don't have the most up to date SDK. The compile error you are seeing is because your version of the Android compat library is less than 26.1.0.
https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context, java.lang.String)
@macdonst hmm you're right, when I go to my android folder (/Users/Jesper/Library/Android/sdk/extras/android/m2repository/com/android/support
) the highest version in those folders is 26.0.0-alpha1
. However, I can't seem to download any version higher than this. I've read some stuff about these versions being in the google maven repository. But I can't seem to download this. From what I've read changes have to be made to the build.gradle
file in order to do this. I don't think there's any check for this in the SDK manager.
Thanks for the help by the way! I really appreciate it :)
I had cordova-android-support-gradle-release
installed, which was messing things up...
So with that out of the way, android 4.4 still seems to be crashing with the same crash log from earlier. I'll try to update google play and report back how it goes.
@macdonst I'm still having this issue. The build error is fixed but the crash on 4.4 and lower is still happening. I'm on 4.1.2 but I believe it's happening on 4.4 as well. I've been looking for more people with this problem and it seems to be related to multidex, though I see multidex is already added to the build.gradle file with this plugin. Is there any way to check whether or not multidex is actually working correctly?
For the record this crash is happening both on a real device and in the emulator.
@jespertheend what version of "Google Play services" is your device running?
@macdonst it appears to be version 11.7.46, the one on the emulator is actually older: 9.2.56
@macdonst I just tried to do a release build and this didn't crash for some reason. So I've got the feeling something else is going on. On iOS <10 my app is crashing as well in dev builds, but this is related to a .js file not being generated and it's trying to load that at runtime. So I think the same could be going on here as well. Though I'm not sure why it constantly gives a stacktrace mentioning firebase. I'll try to do a dev build tomorrow with this .js file generated to figure out if that's the cause or if it is this plugin.
@macdonst Hi macdonst, I face the same problem during the runtime. I'm using android 4.4 to test. And for the push plugin v2.0, it's OK, working fine. And after I upgrade my cordova/cordova-android version and the push plugin version(to 2.1.1), then it comes the following error when I start the app:
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
Are the libraries are different between the 2 versions of the plugin?
also I search this problem, find a soluting : https://stackoverflow.com/questions/37360126/getting-exception-java-lang-noclassdeffounderror-com-google-firebase-firebaseop/38224316#
But it's for Android Project,I don't know how to fix this in this plugin.
I just checked and it's not related to the .js file that doesn't exist since that doesn't work in a dev build either. I don't know why, but for some reason doing cordova build --release
works fine for me whereas cordova build
does not.
Anyone running into the java.lang.ClassNotFoundException for com.google.firebase.provider.FirebaseInitProvider please try the following:
hi, i am not sure if this is the right place to put it, but after updating my cordova android to version 6.4.0 (cordova cli 7.1.0) and dowloading my android sdk's up to API 27 (lowest is 21), i still get the following error:
Error: Users/path/to/project/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/lpath/to/project/platforms/android/src/com/adobe/phonegap/push/FCMService.java:393: error: constructor Builder in class Builder cannot be applied to given types;
mBuilder = new NotificationCompat.Builder(context, channelID);
^
required: Context
found: Context,String
reason: actual and formal argument lists differ in length
/Users/path/to/project/platforms/android/src/com/adobe/phonegap/push/FCMService.java:403: error: constructor Builder in class Builder cannot be applied to given types;
mBuilder = new NotificationCompat.Builder(context, channelID);
^
required: Context
found: Context,String
reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
any ideas on how to fix this issue? I also have downloaded all Google play services referenced SDK tools and support Repository.
@macdonst I had the same issue and updating the Android Gradle plugin worked for me.
Before, I used Gradle 4.4 and Android Gradle plugin 3.0.0, after updating to version 3.0.1, the app starts on Android 4.2.2.
Is there a way to configure this permanently? I updated the file "platforms/android/build.gradle", to have the following:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
But this will be removed when the platforms folder is updated.
All, I've made a change to cordova-android to make the above work around permanent. Once the next version of cordova-android is release I'll bump the dependency and release a new plugin version.
This thread has been automatically locked.
Actual Behavior
The app is not responding and it goes to a white screen when the device is running on android version below 5 but working completely fine on other devices.
Platform and Version (Android 4.4)
This is in my js file. document.addEventListener("deviceready", function(){ var push = PushNotification.init({ "android": { "senderID": "XXXXXXXXXXXXXXXXXX", "forceShow":true, "sound": true, "vibrate": true, }, "ios": { "sound": true, "vibration": true, "badge": true }, "windows": {} });
push.on('registration', function(data) { console.log("registration event: " + data.registrationId); });
push.on('error', function(e) { console.log("push error = " + e.message); });
push.on('notification', (data) => { console.log(data.message); alert(data.message); }); },false);