I added the app to Firebase console and added google json file to app folder.
Then when I try to launch the app it crashes with the following message.
Thanks in Advance.
Error:
07-27 13:18:21.000 26362-26362/? E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.google.samples.quickstart.config, PID: 26362
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/gms/R$string;
at com.google.android.gms.common.internal.zzby.(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown
Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown
Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.R$string" on path: DexPathList[[zip file
"/data/app/com.google.samples.quickstart.config-1/base.apk", zip file
"/data/app/com.google.samples.quickstart.config-1/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/data/app/com.google.samples.quickstart.config-1/lib/arm64,
/system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.android.gms.common.internal.zzby.(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown
Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown
Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Gradle
apply plugin: 'com.android.application'
check.dependsOn 'assembleDebugAndroidTest'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.google.samples.quickstart.config"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:25.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.google.firebase:firebase-config:11.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:1.0.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.samples.quickstart.config" >
<application
android:allowBackup="true"
android:name="android.support.multidex.MultiDexApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It works for me in Android Studio 3 Beta 5, but not in Android Studio 3 and preview 3.1
Try to clean and rebuild your project. Then start it without instant run.
I solved this issue by first adding multidex and then clean the project and rebuilding it.
Related
I am using
pub.devrel:easygoogle:0.2.5
and
com.google.firebase:firebase-core:16.0.1
I am making a simple notification app which sends notification from FCM.
I am following this but at runtime i am getting error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzx;
at com.google.android.gms.measurement.internal.zzt.zzaU(Unknown Source)
at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source)
at com.google.firebase.analytics.connector.AnalyticsConnectorImpl.getInstance(Unknown Source)
at com.google.firebase.analytics.connector.internal.zzb.create(Unknown Source)
at com.google.firebase.components.zzh.zza(SourceFile:28)
at com.google.firebase.components.zzi.get(Unknown Source)
at com.google.firebase.components.zzh.get(SourceFile:39)
at com.google.firebase.components.ComponentContainer$$CC.get(Unknown Source)
at com.google.firebase.components.zzd.get(SourceFile)
at com.google.firebase.components.zzd.zza(SourceFile:68)
at com.google.firebase.FirebaseApp.zze(SourceFile:703)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:328)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:294)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:281)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(SourceFile:37)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(SourceFile:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzx" on path: DexPathList[[zip file "/data/app/com.apneareamein.autostartapp-1/base.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.apneareamein.autostartapp-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.apneareamein.autostartapp-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.android.gms.measurement.internal.zzt.zzaU(Unknown Source)
... 30 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
gradle file -
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.myapp.autostart"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:27.+'
compile 'com.android.support:support-v4:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
compile 'pub.devrel:easygoogle:0.2.5'
compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
I have added build gradle file for more details. i extended EasyMessageService for Notifications.
if any more details is required please let me know.
How can it be resolved?
Thanks in advance.
I had also like this problem. I had an old version google and other services such as google service 1.5.0-beta2 Wanted to run on android 10 devices and gave me an error.
Didn't find class "com.google.android.gms.common.internal.zzx"
Then I updated all libraries to the latest version. Then worked.
I'm pretty sure that my project was working before I moved the project into another folder, and then I moved it back to the original folder while it was open in Android Studios. When I run it it now has an error caused by
java.lang.ClassNotFoundException
Do you think moving the project could have caused this? I've checked other answers and I think my manifest and build.gradle are ok.
Module build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.example.larry.project"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.google.code.gson:gson:2.7'
testCompile 'junit:junit:4.12'
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.larry.project">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
These are mostly just defaults, i dont see how it could cause a problem.
And the error:
11-12 15:55:25.405 4745-4745/com.example.larry.project E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.larry.project, PID: 4745
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.larry.project/com.example.larry.project.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.larry.project.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.larry.project-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.larry.project-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.larry.project.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.larry.lproject-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.larry.project-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I have fixed my question and am reposting it.
I already have tried all the solutions that are in internet but any of them works, this is my gradle:
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.rocketjourney"
minSdkVersion 21
targetSdkVersion 24
versionCode 68
versionName "4.41"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "com.rocketjourney.helpers.CustomTestRunner"
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
resolutionStrategy.force 'com.squareup.okio:okio:1.13.0'
resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.8.0'
}
dexOptions {
javaMaxHeapSize "4g"
jumboMode = true
}`
repositories {
mavenCentral()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
maven { url "https://jitpack.io" }
flatDir { dirs 'libs' }
flatDir { dirs '../aars' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') { transitive = true; }
etc...
}`
my manifest looks like this:
<application
android:name="com.rocketjourney.RJApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
In my RJApplication.class I have this code:
public class RJApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
}
But my error now is this:
11-08 11:54:36.494 5743-5743/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rocketjourney, PID: 5743
java.lang.NoClassDefFoundError: Failed resolution of: Lio/fabric/sdk/android/services/common/FirebaseInfo;
at com.crashlytics.android.CrashlyticsInitProvider.onCreate(CrashlyticsInitProvider.java:22)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.fabric.sdk.android.services.common.FirebaseInfo" on path: DexPathList[[zip file "/data/app/com.rocketjourney-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rocketjourney-2/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.crashlytics.android.CrashlyticsInitProvider.onCreate(CrashlyticsInitProvider.java:22)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Suppressed: java.lang.ClassNotFoundException: io.fabric.sdk.android.services.common.FirebaseInfo
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Hope you guys can help me, I will appreciate it so much!
You don't need to add multidex support if your minSdkVersion is 21.
From the documentation:
Multidex support for Android 5.0 and higher
Android 5.0 (API level 21) and higher uses a runtime called ART which natively supports loading multiple DEX files from APK files. ART performs pre-compilation at app install time which scans for classesN.dex files and compiles them into a single .oat file for execution by the Android device. Therefore, if your minSdkVersion is 21 or higher, you do not need the multidex support library.
So, you need to remove compile 'com.android.support:multidex:1.0.1' from your build.gradle. Then you need to extend your RJApplication with Application. Also remove MultiDex.install(this); from your attachBaseContext().
all you need to do is set multiDexEnabled to true by adding multiDexEnabled true. Please refer to Configure your app for multidex
`
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
`I created a sample project and shared the debug .apk file via google drive and tried to install it crashed. I could install the application from USB without a problem. I am getting following. I posted my gradle file. not sure what's going on
05-22 11:54:57.363 22469-22469/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: chin.demo.app.com.nm, PID: 22469
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{chin.demo.app.com.nm/chin.demo.app.com.nm.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "chin.demo.app.com.nm.MainActivity" on path: DexPathList[[zip file "/data/app/chin.demo.app.com.nm-1/base.apk"],nativeLibraryDirectories=[/data/app/chin.demo.app.com.nm-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "chin.demo.app.com.nm.MainActivity" on path: DexPathList[[zip file "/data/app/chin.demo.app.com.nm-1/base.apk"],nativeLibraryDirectories=[/data/app/chin.demo.app.com.nm-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: chin.demo.app.com.nm.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "chin.demo.app.com.nm"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
`
Try this command in your CMD/Terminal to build apk : gradlew assembleDebug
Generate apk file using AndroidStudio
BUILD -> Build APK
OR
// Enabling multidex support.
multiDexEnabled true
OR
Right click on your project and select Properties.
Select Java Build Path from the menu on the left.
Select the Order and Export tab.
From the list make sure the libraries or external jars you added to your project are checked.
Finally, clean your project & run.
Hope it works.
i got simmilar post but nothing working
i have android studio 2.3.1
gradle version 2.3.1
appcompat-v7:25.3.1
I create a new project by android studio(one that is automatically created by Android Studio(Hello Word)). I haven't write any thing in it.
When i install app using usb via android studio it works perfectly
but same app if i open it from it's icon ,i got these errors
One more i noticed that size of apk is 500-600kb ,early it used to be around for hello world(default by android studio) Apk 2.3Mb
FATAL EXCEPTION: main
Process: in.codebucket.check, PID: 32397
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.codebucket.check/in.codebucket.check.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "in.codebucket.check.MainActivity" on path: DexPathList[[zip file "/data/app/in.codebucket.check-1/base.apk"],nativeLibraryDirectories=[/data/app/in.codebucket.check-1/lib/x86, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "in.codebucket.check.MainActivity" on path: DexPathList[[zip file "/data/app/in.codebucket.check-1/base.apk"],nativeLibraryDirectories=[/data/app/in.codebucket.check-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: in.codebucket.check.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
My xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.codebucket.check.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
My MainActivity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
my Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.codebucket.check">
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
gradle(Module:App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "in.codebucket.check"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
gradle(Project)
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Got the solution ,it is happening because of instant run,
Just disable it
Goto :
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
No need to disable instant run, just remove the app from device/emulator and clean the project and install it again.
For me the problem was that the Gradle dependencies wen't matching. Here's what solved it for me:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.and.myApp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-fexceptions"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'jp.wasabeef:blurry:2.1.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//noinspection GradleCompatible
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
}
For me, it is after I add the code to use getFusedLocationProviderClient, I get crashes
process: no.onmyway133.myapp, PID: 10538
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
at com.google.android.gms.location.LocationServices.<clinit>(Unknown Source)
at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source)
at no.onmyway133.myapp.maps.MapsActivity.onCreate(MapsActivity.kt:22)
The problem is the warning in build.gradle, it warns that both should use the same version, otherwise there will be potential for runtime crashes.
So the fix is to specify the same version
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation "com.google.android.gms:play-services-location:15.0.1"