Today I tested my app on a new device (see below) and I'm getting an exception right at launch. I can't event start the main activity.
Device: Genymotion Samsung Galaxy S2 - Android 4.1.1 - API 16
No google play services installed.
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.firebase.g
at com.google.firebase.b.a(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1058)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4560)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
gradle build:
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.app"
minSdkVersion 10
targetSdkVersion 21
multiDexEnabled true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3#aar'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
}
Is it crashing because of missing Play Services?
Note: I have implemented firebase about a month ago, and It's working on other devices.
Although you have multiDexEnabled true in your build.gradle file, you are missing compile 'com.android.support:multidex:1.0.1' in your dependencies. I doubt that Mulidex is working. Review the Multidex configuration instructions and make sure you have done everything correctly.
Also, it is not good practice to include compile 'com.google.android.gms:play-services:9.4.0'. That adds all the Google Play and Firebase libraries to you app, increasing build time and the size of the APK file. Replace the dependency on play-services:9.4.0 with only the libraries you need. A list of the Google Play libraries is provided here, the Firebase libraries are listed here.
Try adding this apply plugin: 'com.google.gms.google-services' to the end of your gradle build file
You're correct, Firebase requires Google play services. As mentioned here in the release announcement for Google Play Services 9.0:
Google Play Services 9.0
Firebase was built using Google Play services 9.0
Add this line in the Application Tag on manifest file:
android:name="android.support.multidex.MultiDexApplication"
Related
I'm trying to write a simple app with a WebView, but when I create a WebView I get an error:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController;
I searched and found that TracingController is implemented from api level 28, but I only have 27.
How can I resolve this?
Might be late but helpful if someone has the same issue.I had same issue on my project and I figured out that issue is with the SDK version 28.
- If you use the below sets of dependencies then you will not have this issue.
compileSdkVersion 27
buildToolsVersion '28.0.3'
minSdkVersion 16
targetSdkVersion 26
Also, I have included the dependencies used in my project. I have used MoPub SDK for Ads and Google AdMob & Facebook mediation adapters.
compile "com.android.support:appcompat-v7:27.1.1"
compile "com.android.support:design:27.1.1"
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.3'
compile "com.google.firebase:firebase-core:16.0.1"
compile "com.google.firebase:firebase-ads:15.0.1"
compile "com.google.android.gms:play-services-analytics:15.0.0"
compile "com.google.firebase:firebase-config:15.0.0"
compile 'com.google.android.ads.consent:consent-library:1.0.6'
// Glide
compile 'com.github.bumptech.glide:glide:3.7.0'
/* Mopub SDK */
compile('com.mopub:mopub-sdk:5.3.0#aar') {
transitive = true
}
compile 'com.mopub.mediation:admob:15.0.0.11'
compile 'com.mopub.mediation:facebookaudiencenetwork:5.0.0.0'
compile 'com.facebook.android:audience-network-sdk:5.0.0'
same issue here, only appearing on Android 8 in ionic after building with --release. The app shows the splash screen and then is stuck in white screen
I'm trying to include Firebase in my Android project. Running it, throws me this error:
Google Play services out of date. Requires 11910000 but found 11577470
I found several links about this here, most of them saying to downgrade to:
compile 'com.google.android.gms:play-services:9.6.0'
This doesn't work for me anymore, because I use SDK 26 and it throws incompatibilities errors with other libraries.
Here are my gradle files:
(Module):`
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
}
`App:
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.project"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
And as you can see here my Google Services is updated as well.
In my log I get these errors:
I/FirebaseCrash: Sending crashes
W/FirebaseInstanceId: No response
E/FirebaseInstanceId: Topic sync failed: TIMEOUT
E/FirebaseInstanceId: Topic sync failed: SERVICE_NOT_AVAILABLE
W/FirebaseInstanceId: No response
E/FirebaseInstanceId: Topic sync failed: TIMEOUT
Does anyone know how I could resolve this problem? Any tips are appreciated. Thanks.
I had the same issue, and had to move down to API 21 emulator image with google apps. That one is more up to date, and works.
It means that the Play Services APK on your device is older than the version you requested in your app.
If this is an emulator, you'll want to use the ones with "Google Play" in their names, not "Google APIs." The latter are always behind schedule and require a full image update to get the latest Play Services version whereas the former give you the Play Store which will update Play Services for you. If this is a device, make to update this app.
BTW, you should be showing a notification or dialog in your app if Play Services isn't available. See how to check for availability.
guys i have two questions:
1) how to test complete app (i mean run test, not unit) on each api from minSDK version which i set up. Is it any auto process for that?
2) after publish my app i have ANR error on my app publish console (system run 4.4 Kitkat):
java.lang.RuntimeException:
at android.app.ActivityThread.installProvider(ActivityThread.java:5011)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4996)
i set up avd emulator with similar config on my android studio i after compile i have below exception:
1829-2839/com.google.android.gms.persistent E/LoadManifestTask: Can't find Chimera operation impl class com.google.android.location.copresence.GcmRegistrationChimeraReceiver dropping operation
java.lang.ClassNotFoundException: Didn't find class "com.google.android.location.copresence.GcmRegistrationChimeraReceiver" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/priv-app/PrebuiltGmsCore.apk", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes2.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes3.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes4.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes5.zip"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at bws.<init>(:com.google.android.gms:799)
at bwt.run(:com.google.android.gms:2049)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
[ 05-25 03:04:16.195 1623: 1638 D/ ]
HostConnection::get() New Host Connection established 0xb9183a30, tid 1638
Any Idea what cuse this problem?
My app work fine on Lollipop and Nugat.
I paste also my gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'com.fff.hhh'
minSdkVersion 15
targetSdkVersion 25
versionCode 8
versionName '4.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
As described official docs:
You are strongly encouraged to use the GoogleApiClient class to
access Google Play services features. This approach allows you to
attach an OnConnectionFailedListener object to your client. To
detect if the device has the appropriate version of the Google Play
services APK, implement the onConnectionFailed() callback method. If
the connection fails due to a missing or out-of-date version of the
Google Play APK, the callback receives an error code such as
SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or
SERVICE_DISABLED. ... Another approach is to use the
isGooglePlayServicesAvailable() method. You get a reference to the
singleton object that provides this method using
GoogleApiAvailability.getInstance(). You might call this method in
the onResume() method of the main activity. If the result code is
SUCCESS, then the Google Play services APK is up-to-date and you can
continue to make a connection.
Please make sure you're following these rules.
To test the app against the particular version :
1. Write espresso test
2. run those tests on the device with desired api level
To solve the gcm problem Add
apply plugin: 'com.google.gms.google-services'
at the end of your build.gradle you have pasted above.
Hi I'm learning to use Firebase from an Udacity Course.
I got this error when I ran my app and have no clue about it.
11-23 16:48:34.995 3947-3947/com.google.firebase.udacity.friendlychat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.udacity.friendlychat, PID: 3841
java.lang.NoSuchMethodError: No virtual method zzait()Ljava/util/ArrayList;
in class Lcom/google/android/gms/auth/api/signin/GoogleSignInOptions;
or its super classes (declaration of 'com.google.android.gms.auth.api.signin.GoogleSignInOptions' appears in /data/data/com.google.firebase.udacity.friendlychat/files/.jrebel/load-dexes/bundle12/libraries24.zip)
at com.google.android.gms.auth.api.Auth$3.zza(Unknown Source)
at com.google.android.gms.auth.api.Auth$3.zzp(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.addApi(Unknown Source)
at com.firebase.ui.auth.util.CredentialsAPI.initGoogleApiClient(CredentialsAPI.java:147)
at com.firebase.ui.auth.util.CredentialsAPI.<init>(CredentialsAPI.java:65)
at com.firebase.ui.auth.ui.ChooseAccountActivity.onCreate(ChooseAccountActivity.java:102)
at android.app.Activity.performCreate(Activity.java:6100)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) at com.zeroturnaround.jrebel.android.agent.JRebelInstrumentation.callActivityOnCreate(SourceFile:93)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
11-23 16:48:35.176 3947-3975/com.google.firebase.udacity.friendlychatE/GED: Failed to get GED Log Buf, err(0)
Can anyone help me?
UPDATE build.gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
// Firebase
compile 'com.google.firebase:firebase-database:10.0.0'
compile 'com.firebaseui:firebase-ui-database:1.0.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.0.0'
// Firebase Auth
compile 'com.google.firebase:firebase-auth:10.0.0'
}
apply plugin: 'com.google.gms.google-services'
Matching the versions resolves this.
In Compatibility with Firebase / Google Play Services Libraries, it matches
FirebaseUI Version Firebase/Play Services Version
1.0.0 9.8.0
So if dependencies are changed to
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
instead of
compile 'com.google.firebase:firebase-database:10.0.0'
compile 'com.google.firebase:firebase-auth:10.0.0'
compile 'com.firebaseui:firebase-ui-auth:1.0.0'
which is the latest available firebase version for firebaseUI version, the app works fine
This is most likely do to a version incompatibility between Firebase, and FirebaseUI. I ran into the same issue, and spent 30-45 min trying to figure it out. Ultimately what I did in order to keep going with the "Firebase in a Weekend" tutorial was:
git checkout 1.04-firebase-auth-firebaseui-signin
This will switch to the branch at this point in the tutorial. It works fine after doing so.
Maybe not the ideal answer as to what the problem is, but will get you going again with the course.
You just need to add :
compile 'com.google.android.gms:play-services-auth:x.x.x'(find the right version here). They missed to say that you also need to add play-services-auth dependency for google authentication to work.
I was following the Firebase guide to adding FCM, and so I added the following dependencies to my app gradle:
compile 'com.google.android.gms:play-services:9.0.0'
apply plugin: 'com.google.gms.google-services'
And this one to my project gradle:
classpath 'com.google.gms:google-services:3.0.0'
After this, I added the google-services.json from the Firebase console settings by downloading it and adding it to my app directory.
Now I'm getting this error:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
If I follow the instructions and have my application to support multidex, my application crashes as soon as it launches.
Here is the error after adding multidex to my app:
05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine W/dalvikvm: VFY: unable to resolve static field 8723 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416b5e30)05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.cryogenos.pearsonvisionlimousine, PID: 19812java.lang.NoClassDefFoundError: com.google.android.gms.R$stringat com.google.android.gms.common.internal.zzah.<init>
(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1609)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1574)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5643)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5206)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5143)
at android.app.ActivityThread.access$1500(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5883)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:688)
at dalvik.system.NativeStart.main(Native Method)
My phone's google play services is 9.0.0+.
I have updated to the latest play services and the repository in SDK manager.
EDIT:
My app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.cryogenos.pearsonvisionlimousine"
minSdkVersion 19
targetSdkVersion 23
versionCode 3
versionName "2.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
One possible way to avoid 64k Dex error is by including only those APIs which your app needs from Google Play Services.
Selectively compiling APIs into your executable
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:9.0.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:9.0.0'
compile 'com.google.android.gms:play-services-wearable:9.0.0'
UPDATED
Well I read the doc, which says
Apps that rely on the Play Services SDK should always check the device for a compatible Google Play services APK before accessing Google Play services features
So you only need to check Google Play Service is available or not. And to do this you only need Google Actions, Base Client Library API.
compile 'com.google.android.gms:play-services-base:9.0.0'
as explained in documentation use Selectively compiling APIs into your executable which is best approach for you(take it in first priority insted of Multi Dex), because Multi-dex have some limitations check before proceed.
Avoiding the 64K Limit - Proguard will help you
Before configuring your app to enable use of 64K or more method
references, you should take steps to reduce the total number of
references called by your app code, including methods defined by your
app code or included libraries. The following strategies can help you
avoid hitting the dex reference limit:
Review your app's direct and transitive dependencies - Ensure any large library dependency you include in your app is used in a manner
that outweighs the amount of code being added to the application. A
common anti-pattern is to include a very large library because a few
utility methods were useful. Reducing your app code dependencies can
often help you avoid the dex reference limit.
Remove unused code with ProGuard - Configure the ProGuard settings for your app to run ProGuard and ensure you have shrinking enabled for
release builds. Enabling shrinking ensures you are not shipping unused
code with your APKs.
Using these techniques can help you avoid the
build configuration changes required to enable more method references
in your app. These steps can also decrease the size of your APKs,
which is particularly important for markets where bandwidth costs are
high.
So, try to avoid Multi-Dex
one more thing when you use compile 'com.android.support:design:23.1.1' then you not need to use compile 'com.android.support:appcompat-v7:23.1.1' and compile 'com.android.support:support-v4:23.1.1'. so remove v7 & v4 from build.gradle file
First check if the multidex has really worked, you can do that by renaming the apk file to zip and extracting it. There should 2 multiple classes.dex files.
Secondly, it can also happen if earlier to reduce the method you must have used proguard, so just comment the use of proguard and it should work.
Otherwise paste your exception here.
Something wrong.
Checking the doc you only need this dependency
dependencies {
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
So you can remove this dependency
//compile 'com.google.android.gms:play-services:9.0.0'
If it is not enough and you have more than 65536 methods you can use the multidex support.
Just add these lines in the build.gradle:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also in your Manifest add the MultiDexApplication class from the multidex support library to the application element
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
and override attachBaseContext method:
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
MultiDex.install(this);
}
If you are using a own Application class, change the parent class from Application to MultiDexApplication.