I was getting this weird error on my google developer console. So i used google Cloud Test Lab to See whats really happening. turns out my app is failing on almost all devic
You'd try following Code snippet:
defaultConfig {
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
public class Controller extends Application {
@Override
protected void attachBaseContext(Context newBase)
{
super.attachBaseContext(newBase);
MultiDex.install(this);
}
}
Turns out my usage of MultiDex
was wrong and that causes this error.
This should have really been mentioned in the official documentation somewhere.
In Gradle.build (app level)
dependencies {
compile 'com.android.support:multidex:1.0.1'
In the Manifest, add
<application
android:name=".Global"
...
In the Application class,
public class Global extends MultiDexApplication {
...
}
If this can help other I solved this using this, although this is nowhere linked with Firebase but it actually solved my crash
Add compile 'com.android.support:multidex:1.0.1'
to app/build.gradle.
Add android:name="android.support.multidex.MultiDexApplication"
to the application tag in AndroidManifest.xml.
If you are using a custom Application class, skip the AndroidManifest.xml and make your Application class extend MultiDexApplication instead of Application.
You have to use the com.google.firebase:firebase-ads:9.0.2 AdMob on Android dependencies,
compile 'com.google.firebase:firebase-ads:9.0.2'
and remove your
play-services (com.google.android.gms: play-services:9.0.2)
It works for me!
with my case: Use FCM and Google map
//for FCM
compile 'com.google.firebase:firebase-messaging:9.4.0'
//for Map
compile 'com.google.android.gms:play-services:9.4.0'
I have fixed: Removed
compile 'com.google.android.gms:play-services:9.4.0'
and Used
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
It worked fine.
In Android 4.4 the solucion was similar like this(https://stackoverflow.com/a/38707231/3377472):
-I have Google Play services revision 33
1) Configure build.gradle and and dependencies
Enabled multidex support and add library of multidex
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "packagename"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
//------- Enabling multidex support----------.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "3g"//use 3Gb of ram to launch android
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1' // 1.0.0
// if you are using google maps
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
}
2)Edit Manifest, and add this android:name
<application
android:name="android.support.multidex.MultiDexApplication"
...
.....
activity
android:name="packagename.Application"
....
...
</activity>
3)Application Class
-My application class is:
import android.support.multidex.MultiDex;
public class Application extends AppCompatActivity {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this is the solution
MultiDex.install(this);
setContentView(R.layout.layout_example);
----
----