firebase - FCM - onTokenRefresh is never called on multi-flavored android app -
i have multi-flavored android app. package name same both flavors (com.mycompany.base). in app level gradle file, 2 flavors have own appplication ids (com.mycompany.firstflavor, , com.mycompany.secondflavor).
in past, google play services maps, used both application ids , google-services.json file includes information both flavors. need copy json file app , worked fine.
lately created fcm project in order implement push notification, , added each flavor app using application ids before. @ first, included 1 coppy of json file in suggested location in app. when ran app on 1 flavor, said firebase initialized successfully. however, ontokenrefresh method never called. searched on internet, , there related topics, none of solutions worked in case. when ran app on flavor, app kept crashing error message: java.lang.nosuchmethoderror: no static method zzb(ljava/lang/object;ljava/lang/object;)ljava/lang/object; in class lcom/google/android/gms/common/internal/zzab; or super classes (declaration of 'com.google.android.gms.common.internal.zzab' appears in /data/app/com.suran.dwmobile-2/base.apk:classes2.dex). issue happened on both real devices , simulators. copied json file 2 locations suggested read online. same json file appears in 2 places, under each flavo, e.g., app/src/firstflavor, , app/src/secondflavor. didn't @ all, , still had same issue. , debug mode.
when ran app build variant set release, both flavors got error message: com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: com/google/android/gms/common/internal/zzv$zza$zza.class. found answers similar issues, none of them can solve problem.
here part of manifest file may useful debugging:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:amazon="http://schemas.amazon.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.mycompany.base" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="10" android:targetsdkversion="21" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.get_tasks" /> <uses-permission android:name="archos.permission.fullscreen.full" /> <uses-permission android:name="android.permission.expand_status_bar"/> <uses-permission android:name="android.permission.send_sms" android:required="false" /> <uses-permission android:name="android.permission.camera" android:required="false"/> <uses-feature android:name="android.permission.access_network_state" android:required="false"/> <uses-feature android:name="android.permission.access_coarse_location" android:required="false" /> <uses-feature android:name="android.permission.access_fine_location" android:required="false" /> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.front" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> <uses-feature android:name="android.hardware.telephony" android:required="false" /> <uses-feature android:glesversion="0x00020000" android:required="false"/> <application android:name=".application.baseapplication" android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:largeheap="true" android:theme="@style/companytheme" > <service android:name=".fbinstanceservice"> <intent-filter> <action android:name="come.google.firebase.instance_id_event" /> </intent-filter> </service> <service android:name=".fbmessagingservice"> <intent-filter> <action android:name="com.google.firebase.messaging_event" /> </intent-filter> </service> </application> </manifest>
here app level gradle file:
apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion '25.0.0' uselibrary 'org.apache.http.legacy' defaultconfig { minsdkversion 10 targetsdkversion 23 multidexenabled true testinstrumentationrunner "android.support.test.runner.androidjunitrunner" } signingconfigs { firstflavorrelease { storefile file("xxxxxx.jks"); storepassword("xxxxxxx"); keyalias "xxxxxxx"; keypassword "xxxxxxx"; } secondflavorrelease { storefile file("xxxxxxx.jks"); storepassword("xxxxxxxx"); keyalias "xxxxxxxxx"; keypassword "xxxxxxxx"; } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } productflavors { firstflavor { applicationid = "com.mycompany.firstflavor" signingconfig signingconfigs.firstflavorrelease versioncode 1000 versionname "1.9.2" } secondflavor { applicationid = "com.mycompany.secondflavor" signingconfig signingconfigs.secondflavorrelease versioncode 1000 versionname "1.2.2" } } testoptions { unittests.returndefaultvalues = true } } dependencies { compile project(':myappcore') compile files('libs/amazonmaps-1.0.2.jar') compile files('libs/zbar.jar') testcompile 'junit:junit:4.12' testcompile 'org.mockito:mockito-core:1.9.5' androidtestcompile 'com.linkedin.dexmaker:dexmaker-mockito:2.2.0' androidtestcompile 'com.android.support:support-annotations:23.4.0' androidtestcompile 'com.android.support.test:runner:0.5' androidtestcompile 'com.android.support.test:rules:0.5' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidtestcompile "com.android.support.test.espresso:espresso-intents:2.2.1" testcompile 'org.powermock:powermock-api-mockito:1.6.1' testcompile 'org.powermock:powermock-module-junit4-rule-agent:1.6.1' testcompile 'org.powermock:powermock-module-junit4-rule:1.6.1' testcompile 'org.powermock:powermock-module-junit4:1.6.1' testcompile "org.robolectric:robolectric:3.2.2" compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.google.code.gson:gson:2.2.4' compile 'com.google.android.gms:play-services-maps:9.0.0' compile 'com.google.android.gms:play-services-gcm:9.0.0' compile 'com.google.android.gms:play-services-auth:9.0.0' compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:mediarouter-v7:23.4.0' compile 'com.google.firebase:firebase-core:9.2.1' compile 'com.google.firebase:firebase-messaging:9.2.1' compile 'org.jsoup:jsoup:1.10.2' } apply plugin: 'com.google.gms.google-services'
and here project level gradle file:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.google.gms:google-services:3.0.0' } } allprojects { repositories { jcenter() } }
any appreciated!
after few days struggling issue, found problem was. in manifest file, incorrectly set android name service action be: come.google.firebase.instance_id_event rather com.google.firebase.instance_id_event.
Comments
Post a Comment