I'm developing a chat application, it works for android 21 very good, but on SDK lower 21 as 18 or 19 that cause this problem
11-03 01:49:22.676 20966-20966/ E/AndroidRuntime: FATAL EXCEPTION: main Process: , PID: 20966 java.lang.RuntimeException: Unable to instantiate application .Application: java.lang.ClassNotFoundException: Didn't find class ".Application" on path: DexPathList[[zip file "/data/app/d-9.apk"],nativeLibraryDirectories=[/data/app-lib/-9, /vendor/lib, /system/lib]] at android.app.LoadedApk.makeApplication(LoadedApk.java:516) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4703) at android.app.ActivityThread.access$1600(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) 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:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "dev.karim.dardesh.Application" on path: DexPathList[[zip file "/data/app/dev.karim.dardesh-9.apk"],nativeLibraryDirectories=[/data/app-lib/dev.karim.dardesh-9, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at android.app.Instrumentation.newApplication(Instrumentation.java:981) at android.app.LoadedApk.makeApplication(LoadedApk.java:511) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4703) at android.app.ActivityThread.access$1600(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) 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:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method)
and I overridden Attachbasecontext on application class
public class Application extends android.app.Application{
@Override
public void onCreate() {
super.onCreate();
Firebase.setAndroidContext(this);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and am using in gradle file:
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
this gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "pakage.com"
minSdkVersion 17
targetSdkVersion 24
versionCode 18
versionName "18"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
additionalParameters('jack.incremental': 'true')
}
}
compileOptions {
incremental true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize '4096m'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android:support-v4:r7'
}
apply plugin: 'com.google.gms.google-services'
in addition my project deal with firebase realtime database:
hint/no any solution here is resolve me:
please help me
I had the same issue when I updated Android Studio to 3.0. If you did that too, use the 2.3 version instead. Worked for me!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With