0

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

1 Answers1

0
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

defvs Daniel
  • 300
  • 3
  • 15
  • I actually realised that the SDK is not the same right after posting this, but even after installing it (Only thing that wasn't installed was Google Play Services), it still crashes with the same result – Dean Ayalon May 28 '17 at 19:15
  • Nevermind that, I just needed to uninstall the app and relaunch the emulator after installing that SDK, Thank you :D – Dean Ayalon May 28 '17 at 19:20
  • Nice you fixed it. Good luck for your project, fellow coder :) – defvs Daniel May 28 '17 at 19:21