Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
110 stars 139 forks source link

Android apps always crash at startup when compiling with PhoneGap Build #189

Closed blupu closed 8 years ago

blupu commented 8 years ago

Until recently, Android apps worked just fine with PushWoosh when compiling with PhoneGap Build.

We're now facing systematic crash at startup :-(

We get the following error log: 06-25 15:59:19.323: E/GMPM(4668): GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.

DimanAM commented 8 years ago

This log is harmless. You missed the actual crash log. Try searching adb logcat for "Exception" occurrences. BTW make sure you use pushwoosh-pgb-plugin for PhoneGap Build not pushwoosh-cordova-plugin.

lpointet commented 8 years ago

Hi @DimanAM,

I just ran some tests with pushwoosh-pgb-plugin version 5.1.2, using PhoneGap Build with the following configuration:

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns       = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "com.uncatcrea.googleanalytics"
        versionCode = "10312"
        version     = "1.3.12" >

    <name>Test App - Google Analytics</name>

    <description>Test the Google Analytics addon for WP-AppKit</description>

    <author href="http://uncategorized-creations.com" email="myemail">Lionel Pointet</author>

    <gap:platform name="android" />
    <preference name="android-build-tool" value="gradle" />

    <preference name="phonegap-version" value="cli-6.1.0" />
    <preference name="permissions" value="none"/>

    <preference name="disallowOverscroll" value="true" />
    <preference name="webviewbounce" value="false" />
    <preference name="android-versionCode" value="10312" />

    <!-- PhoneGap plugin declaration -->
    <plugin name="cordova-plugin-inappbrowser" source="npm" />
    <plugin name="cordova-plugin-network-information" source="npm" />
    <plugin name="cordova-plugin-whitelist" source="npm" />
    <plugin name="cordova-plugin-splashscreen" source="npm" />
    <plugin name="cordova-plugin-device" source="npm" />
    <plugin name="pushwoosh-pgb-plugin" spec="5.1.2" source="npm" />

    <!-- Whitelist policy  -->
    <access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />

    <!-- SplashScreen configuration -->
    <preference name="SplashScreen" value="splash" />
    <preference name="SplashScreenDelay" value="10000" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="ShowSplashScreenSpinner" value="false" />

    <!-- Icons and Splashscreens declaration -->

    <icon src="icon.png" gap:platform="android" />
    <icon src="icons/icon-wp-appkit-ldpi.png" gap:platform="android" gap:qualifier="ldpi" />
    <icon src="icons/icon-wp-appkit-mdpi.png" gap:platform="android" gap:qualifier="mdpi" />
    <icon src="icons/icon-wp-appkit-hdpi.png" gap:platform="android" gap:qualifier="hdpi" />
    <icon src="icons/icon-wp-appkit-xhdpi.png" gap:platform="android" gap:qualifier="xhdpi" />
    <icon src="icons/icon-wp-appkit-xxhdpi.png" gap:platform="android" gap:qualifier="xxhdpi" />
    <icon src="icons/icon-wp-appkit-xxxhdpi.png" gap:platform="android" gap:qualifier="xxxhdpi" />

    <gap:splash src="splash.9.png" gap:platform="android" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-ldpi.9.png" gap:platform="android" gap:qualifier="ldpi" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-mdpi.9.png" gap:platform="android" gap:qualifier="mdpi" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-hdpi.9.png" gap:platform="android" gap:qualifier="hdpi" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-xhdpi.9.png" gap:platform="android" gap:qualifier="xhdpi" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-xxhdpi.9.png" gap:platform="android" gap:qualifier="xxhdpi" />
    <gap:splash src="splashscreens/splashscreen-wp-appkit-xxxhdpi.9.png" gap:platform="android" gap:qualifier="xxxhdpi" />

</widget>

The application is still crashing during registerDevice call due to the following exception:

06-29 22:40:11.156: V/Pushwoosh(30636): [GCMRegistrationService] Intent action = com.pushwoosh.gcm.intent.REGISTER
06-29 22:40:11.162: E/AndroidRuntime(30636): FATAL EXCEPTION: IntentService[GCMRegistrationService]
06-29 22:40:11.162: E/AndroidRuntime(30636): Process: com.uncatcrea.googleanalytics, PID: 30636
06-29 22:40:11.162: E/AndroidRuntime(30636): java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/com.uncatcrea.googleanalytics-1/base.apk)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.google.android.gms.iid.zzd.<init>(Unknown Source)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.pushwoosh.GCMRegistrationService.register(GCMRegistrationService.java:37)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at com.pushwoosh.GCMRegistrationService.onHandleIntent(GCMRegistrationService.java:106)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at android.os.Looper.loop(Looper.java:152)
06-29 22:40:11.162: E/AndroidRuntime(30636):    at android.os.HandlerThread.run(HandlerThread.java:61)
06-29 22:40:11.162: D/AppTracker(30636): App Event: crash
06-29 22:40:11.219: I/Process(30636): Sending signal. PID: 30636 SIG: 9

Benjamin pasted the original error happening at app launch, which I guess is the cause of the crash eventually.

I'm experiencing the exact same issue running this test with pushwoosh-cordova-plugin version 5.1.2, letting the other configurations as is.

If it can help you, our PushWoosh initialization code is the following:

function init() {
        pushNotification = cordova.require( 'pushwoosh-cordova-plugin.PushNotification' );

        //set push notifications handler
        document.addEventListener( 'push-notification', pushwoosh.handleNotif );

        //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
        pushNotification.onDeviceReady( { projectid: Config.options.pushwoosh.googleid, pw_appid : Config.options.pushwoosh.pwid } );

        //register for pushes
        pushNotification.registerDevice();
}

Both Config.options.pushwoosh.googleid and Config.options.pushwoosh.pwid have their correct values of course, and everything runs smoothly until registerDevice.

Thanks a lot for your help with that.

lpointet commented 8 years ago

OK now I have a weird behaviour: including pushwoosh-pgb-plugin with version 5.1.2-1 is working even if PhoneGap Build is showing "5.1.2" as installed version, just like if I was specifying 5.1.2, which doesn't work... I guess, I'll go with 5.1.2-1 for now.

DimanAM commented 8 years ago

PhoneGap Build uses outdated Android SDK that does not still include Google Play Services v9.0.1. Whereas Android Support V4 24.0 is only compatible with Google Play Services v9.0.1+. pushwoosh-pgb-plugin@5.1.2-1 is the exact version that "fixes" this problem by forsing Android Support V4 23.4.0 version.

blupu commented 8 years ago

Well we can say that PGB has support problems :-\ Anyway, we're good for the moment. Thank you fro your help.