java.lang.ClassNotFoundException : dalvik.system.BaseDexClassLoader.findClass - java

I'm continuously getting this error report in my Google Play developer console. It look like MultiDex error.
java.lang.RuntimeException:
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4514)
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:5299)
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:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
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.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
I already added this to gradle.build:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
try {
MultiDex.install(this);
}catch (RuntimeException e){
e.printStackTrace();
}catch (Exception e){
e.printStackTrace();
}
}
I'm still getting this error in android 4.4,5.0,5.1, 6.0. Please help !!

There are multiple variants of the java.lang.ClassNotFoundException in Android, most of them are caused by a wrong Proguard configuration, IDE not closing correctly the previous launched instance of the device during build time etc.
Follow Unexpected crash in BaseDexClassLoader for more details.

It might be because of conflict in dependencies (same class may exists in two libraries).
So search for BaseDexClassLoader class in your dependencies.

Related

How to Resolve Android App Crashes in Release Build Type But Works in Debug Build Type

Android app crashes in phone when build using Release Type but works fine when build using debug build type or if debugging is enabled in release mode.
Logcat error are showing verify error due to one of the abstract class
There are no proguard files in the application. i have tried by adding
'useProguard false' in build.gradle but it won't help
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "com.newgen.mcap.srei"
minSdkVersion 21
targetSdkVersion 28
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
checkReleaseBuilds false
disable "ResourceType"
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/com.antlersoft.android.db_0.1.6.jar')
compile files('libs/commons-lang3-3.1.jar')
compile files('libs/dmsapi.jar')
compile files('libs/ImgAndro.jar')
compile files('libs/NGSecurity.jar')
}
Logcat error in here:
--------- beginning of crash
2019-01-14 16:34:28.599 16678-16696/com.newgen.mcap.srei E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.newgen.mcap.srei, PID: 16678
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.VerifyError: Rejecting class com.newgen.mcap.client.custom.CustomHelper_1_1 that attempts to sub-type erroneous class com.newgen.mcap.client.util.DefaultCustomHelper (declaration of 'com.newgen.mcap.client.custom.CustomHelper_1_1' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109)
at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591)
at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414)
at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145)
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 
Caused by: java.lang.VerifyError: Verifier rejected class com.newgen.mcap.client.util.DefaultCustomHelper: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean) failed to verify: java.lang.String[] com.newgen.mcap.client.util.DefaultCustomHelper.selectMasterData(java.lang.String, java.lang.String, java.util.LinkedHashMap, boolean): [0xCA] returning undefined register (declaration of 'com.newgen.mcap.client.util.DefaultCustomHelper' appears in /data/app/com.newgen.mcap.srei-1/base.apk)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at java.lang.Class.forName(Class.java:326) 
at com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName(NGCaptureSingleton.java:109) 
at com.newgen.mcap.client.util.NGCaptureSingleton.loadXMLConfiguration(NGCaptureSingleton.java:591) 
at com.newgen.mcap.client.util.NGCaptureSingleton.initConfiguration(NGCaptureSingleton.java:414) 
at com.newgen.mcap.client.util.NGCaptureSingleton.setAssets(NGCaptureSingleton.java:96) 
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:145) 
at com.newgen.mcap.client.gui.SplashScreen$MastersUpdationTask.doInBackground(SplashScreen.java:120) 
at android.os.AsyncTask$2.call(AsyncTask.java:305) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761)
My question is not a duplicate of Link
as crash is due to build type and not due to android api level. And i have tried the accepted answer by deleting the build and release folder before building apk.
It is not related to debug/release build. You should handle exception in
com.newgen.mcap.client.util.NGCaptureSingleton.getDefaultCustomHelperForName
(NGCaptureSingleton.java:109)
Steps 1: Open Android Studio Setting and go to Build, Execution, Deployment -> Gradle
Copy Gradle Service Directory Path
In my case that is C:/Users/bhanu.sharma/.gradle
Step 2: Open File Explorer and Paste the Gradle service directory Path
Add the file gradle.properties in here if it is not present
Step 3: Open Android Studio and change project type to Android, You will see
gradle.properties file here
Step 4: Add the line android.enableD8=false in gradle.properties file.
Step 5: Clean and Build the signed apk.

Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;

I got this error when we run apk file of our application. In build.gradle we set multidex and compile multidex is existed in Gradle file . We changed the version of Firebase versions to above and below but that's did not work for us . This is our full log in Run console :
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.parsinteam.ojoobe, PID: 5141
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 ir.adad.client.LocationMethods.callAndroidLocationService(LocationMethods.java:101)
at ir.adad.client.LocationMethods.<init>(LocationMethods.java:40)
at ir.adad.client.LocationMethods.getInstance(LocationMethods.java:45)
at ir.adad.client.AdadScript.urlParameters(AdadScript.java:390)
at ir.adad.client.AdadScript.downloadClient(AdadScript.java:148)
at ir.adad.client.AdadScript.initializeInternal(AdadScript.java:134)
at ir.adad.client.AdadScript.initializeClient(AdadScript.java:110)
at ir.adad.client.Adad.initialize(Adad.java:22)
at ir.parsinteam.ojoobe.activities.MainActivity.onCreate(MainActivity.java:62)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Api$zzf" on path: DexPathList[[zip file "/data/app/ir.parsinteam.ojoobe-2/base.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_dependencies_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_0_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_1_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_2_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_3_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_4_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_5_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_6_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_7_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_8_apk.apk", zip file "/data/app/ir.parsinteam.ojoobe-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/ir.parsinteam.ojoobe-2/lib/x86, /data/app/ir.parsinteam.ojoobe-2/base.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_dependencies_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_0_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_1_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_2_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_3_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_4_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_5_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_6_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_7_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_8_apk.apk!/lib/x86, /data/app/ir.parsinteam.ojoobe-2/split_lib_slice_9_apk.apk!/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 com.google.android.gms.location.LocationServices.<clinit>(Unknown Source) 
at ir.adad.client.LocationMethods.callAndroidLocationService(LocationMethods.java:101) 
at ir.adad.client.LocationMethods.<init>(LocationMethods.java:40) 
at ir.adad.client.LocationMethods.getInstance(LocationMethods.java:45) 
at ir.adad.client.AdadScript.urlParameters(AdadScript.java:390) 
at ir.adad.client.AdadScript.downloadClient(AdadScript.java:148) 
at ir.adad.client.AdadScript.initializeInternal(AdadScript.java:134) 
at ir.adad.client.AdadScript.initializeClient(AdadScript.java:110) 
at ir.adad.client.Adad.initialize(Adad.java:22) 
at ir.parsinteam.ojoobe.activities.MainActivity.onCreate(MainActivity.java:62) 
at android.app.Activity.performCreate(Activity.java:6662) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6077) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
Application terminated.
In your build.gradle, upgrade play-services-gcm and play-services-location to 15.0.1:
com.google.android.gms:play-services-gcm:15.0.1
com.google.android.gms:play-services-location:15.0.1
This is happen when we try to authenticate user with some authenticate service like AccountKit FirebaseAuth and those service depends on play-services-auth So, Add
implementation 'com.google.android.gms:play-services-auth:16.0.0'
on your build.gradle dependencies
I fixed this issue. Please follow below code.
Added following to android/build.gradle
allprojects {
repositories {
//start here
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '12.0.1'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '12.0.1'
}
}
}
//end
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Well, I am using Account Kit from Facebook. After I adding play-services-auth problem is resolved.
implementation 'com.facebook.android:account-kit-sdk:4.39.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
I was using a react native package
react-native-facebook-account-kit
resolved by adding
implementation 'com.google.android.gms:play-services-auth:16.0.1'
For me i tried adding implementation 'com.google.android.gms:play-services-auth:18.0.0'
didnot work for me..
But after adding the below dependency it worked for me.
implementation 'com.android.support:multidex:1.0.3'
I was having this issue when i enabled proguard, when i'm disabling it I don't get the crash. I fixed it by adding following dependencies in my app level gradle. I have used FCM, Firebase Analytics and google location in my app. So I had to add the following, if u r not using anything then skip it.
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
implementation 'com.google.firebase:firebase-analytics:17.4.3'
Also add the following in your proguard rules file.
-dontshrink
-dontoptimize
-dontwarn
-dontpreverify

java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo

I know this question may be duplicate but I have tried many solutions but I am unable to make my app work. It should be noted that I have enabled Multidex but still getting below error. I am creating a react native app.
FATAL EXCEPTION: main
Process: com.xxxxxx.yyyyyyyy, PID: 3978
java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzbo
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5049)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4623)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4563)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
If you are developing a react native application and above error came , just make sure that all of your dependencies's Gradle are using same version of firebase servces and play service base.
For example :- my app level gradle file contains
compile "com.google.android.gms:play-services-base:11.4.0"
compile "com.google.firebase:firebase-core:11.4.0"
compile "com.google.firebase:firebase-messaging:11.4.0"
compile "com.google.firebase:firebase-analytics:11.4.0"
compile "com.google.firebase:firebase-crash:11.4.0"
compile "com.google.firebase:firebase-ads:11.4.0"
and one react-native library is using
compile "com.google.android.gms:play-services-base:11.8.0"
and other one library is using
compile "com.google.android.gms:play-services-base:+"
so what i did , i changed all services version to 11.8.0.
BTW you can see gradles of all libraries or dependencies when you open your react-native-project/android folder in Android studio
I hope this will solve your issue

Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException

After moving my project to another computer, when trying to run the code (The exact same working code from the first computer), the application crashes.
This is the error in the console:
05-28 21:33:35.502 5021-5021/com.dean.booktown E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dean.booktown, PID: 5021
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.dean.booktown-1/base.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_4_apk.apk"],nativeLibraryDirectories=[/data/app/com.dean.booktown-1/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5244)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4836)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4776)
at android.app.ActivityThread.access$1600(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5525)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.dean.booktown-1/base.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.dean.booktown-1/split_lib_slice_4_apk.apk"],nativeLibraryDirectories=[/data/app/com.dean.booktown-1/lib/arm64, /vendor/lib64, /system/lib64]]
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.ActivityThread.installProvider(ActivityThread.java:5229)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4836) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4776) 
at android.app.ActivityThread.access$1600(ActivityThread.java:157) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5525) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
Suppressed: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
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
I searched for other people with the same problem, and most answers were about not compiling play-services as a whole but only the parts needed, but I already had it that way
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0" /* TODO: Check 25.0.3 */
/* Before update - 24.0.2 */
defaultConfig {
applicationId "com.dean.booktown"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "Beta v0.8.6 'Ready'"
/* To enable Jack Toolchain - required for Java 8 */
/* jackOptions {
enabled true
} */
}
/* To enable Java 8 */
/* compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
} */
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0' /* Error? TODO: Check 25.3.1 */
compile 'com.google.android.gms:play-services-ads:10.2.6' /* AdMob */
compile 'com.github.bumptech.glide:glide:4.0.0-RC0' /* Glide - Loads lightweight images */
compile 'com.android.support:support-v4:23.4.0' /* TODO: Check 25.3.1 */
compile 'com.google.android.gms:play-services-location:10.2.6' /* Required for Firebase, AdMob(?) */
compile 'com.google.firebase:firebase-core:10.2.6' /* Firebase */
compile 'com.google.firebase:firebase-auth:10.2.6' /* Firebase - authentication */
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2' /* The new android ConstraintLayout */
compile 'com.google.firebase:firebase-messaging:10.2.6' /* Firebase - Cloud Messaging */
compile 'com.firebase:firebase-jobdispatcher:0.5.2' /* Firebase - Cloud Messaging Job Dispatcher */
}
apply plugin: 'com.google.gms.google-services'
Maybe the problem is here: My package name is com.dean.booktown
not com.dean.booktown-1
if that really is the problem, where do I find the mistake to fix it, and why did it happen in the first place?
Thank you very much,
Dean
com.dean.booktown-1
This is actually the folder where your APK is installed
Is the SDK and Google tools and libraries installed ? You should double check that since you swapped environment.
Edit;
From this question, is MultiDex enabled ?
MultiDex makes libraries with a lot of classes available to your app. To add it, see answer #2

java.lang.noClassDefFoundError on Android 4.4.4, works on 5.0+

I am getting this error:
12-17 03:59:18.767 7516-8610/io.ustube.ustube E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: io.ustube.ustube, PID: 7516
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
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)
Caused by: java.lang.NoClassDefFoundError: com.google.gson.internal.$Gson$Preconditions
at com.google.gson.reflect.TypeToken.<init>(TypeToken.java:72)
at com.google.gson.reflect.TypeToken.get(TypeToken.java:296)
at com.google.gson.Gson.toJson(Gson.java:644)
at com.google.gson.Gson.toJson(Gson.java:631)
at com.google.gson.Gson.toJson(Gson.java:586)
at com.google.gson.Gson.toJson(Gson.java:566)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:338)
at io.ustube.ustube.LoginActivity$VerifyTask.doInBackground(LoginActivity.java:310)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
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) 
but I know that the mentioned class is a dependency. I've looked through the jar file myself. Also, I only get this error below 5.0.
My gradle file includes compile 'com.google.code.gson:gson:2.5'
NoClassDefFoundError in Java comes when Java Virtual Machine is not
able to find a particular class at runtime which was available during
compile time. For example, if we have a method call from a class or
accessing any static member of a Class and that class is not available
during run-time then JVM will throw NoClassDefFoundError.
You can try with
compile 'com.google.code.gson:gson:2.3'
Then , Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 21 // Set Yours
buildToolsVersion "21.1.0" // Set Yours
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21 // Set Yours
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
More details
DexIndexOverflowException Only When Running Tests
This thing happens a lot. You should be able to fix by doing the following,
multiDexEnabled = false
in your build.gradle file.
If you already have multiDexEnabled = true then change it to false or add this new line.
Use compile 'com.android.support:multidex:1.0.0' then extends MultiDexApplication in your application class.

Categories