Failed resolution of: Ldagger/internal/Preconditions

人走茶凉 提交于 2021-02-07 19:09:38

问题


My app worked well but due to some problem with my operating system Debian I decided to reinstall it and I choose to install Ubuntu-16.04 instead of the last Debian. Now everything is OK.

The problem is my android application. After reinstalling android-studio the stable version, I can not test my application anymore.

Why? Because every time I launch the application, I got this error. I don't know what it means, and after some searching on the internet, I didn't get anywhere.

Here is the stack trace:

10-13 07:47:10.749 1631-1631/com.gre E/AndroidRuntime: FATAL EXCEPTION: main
                                                      Process: com.gre, PID: 1631
                                                      java.lang.NoClassDefFoundError: Failed resolution of: Ldagger/internal/Preconditions;
                                                          at com.gre.di.components.DaggerApplicationComponent$Builder.applicationModule(DaggerApplicationComponent.java:209)
                                                          at com.gre.GreApplication.onCreate(GreApplication.java:47)
                                                          at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
                                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
                                                          at android.app.ActivityThread.access$1600(ActivityThread.java:154)
                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                          at android.os.Looper.loop(Looper.java:135)
                                                          at android.app.ActivityThread.main(ActivityThread.java:5294)
                                                          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:904)
                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
                                                       Caused by: java.lang.ClassNotFoundException: Didn't find class "dagger.internal.Preconditions" on path: DexPathList[[zip file "/data/app/com.gre-1/base.apk", zip file "/data/app/com.gre-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.gre-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.gre-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 com.gre.di.components.DaggerApplicationComponent$Builder.applicationModule(DaggerApplicationComponent.java:209) 
                                                          at com.gre.GreApplication.onCreate(GreApplication.java:47) 
                                                          at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012) 
                                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593) 
                                                          at android.app.ActivityThread.access$1600(ActivityThread.java:154) 
                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382) 
                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                          at android.os.Looper.loop(Looper.java:135) 
                                                          at android.app.ActivityThread.main(ActivityThread.java:5294) 
                                                          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:904) 
                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 
                                                        Suppressed: java.lang.ClassNotFoundException: dagger.internal.Preconditions
                                                          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)
                                                                ... 14 more
                                                       Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

How to solve it please ??

Here is my build.gradle file

    apply plugin: 'com.android.application'
     apply plugin: 'realm-android'
     // apply plugin: 'com.neenbedankt.android-apt'

     android {
         compileSdkVersion 25
         buildToolsVersion '25.0.2' // '23.0.2'

    defaultConfig {
        applicationId "com.gre"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        /*debug {
            applicationIdSuffix ".debug"
        }*/

        /**
         * The 'initWith' property allows you to copy configurations from other build types,
         * so you don't have to configure one from the beginning. You can then configure
         * just the settings you want to change. The following line initializes
         * 'jnidebug' using the debug build type, and changes only the
         * applicationIdSuffix and versionNameSuffix settings.
         */

        jnidebug {

            // This copies the debuggable attribute and debug signing configurations.
            initWith debug

            applicationIdSuffix ".jnidebug"
            jniDebuggable true
        }
    }
    dexOptions {
        // javaMaxHeapSize "2048M"
        javaMaxHeapSize "4g"
    }
    configurations.all {
        // all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'configurations.all {
        // OkHttp 3.5.0+ includes the websockets API, so we need this to prevent a conflict
        exclude module: 'okhttp-ws'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('io.socket:socket.io-client:0.8.1') {
        exclude group: 'org.json', module: 'json'
    }

    /*compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-appindexing:10.0.1'*/

    // compile 'com.android.support.constraint:constraint-layout:1.0.2'

    // Android
    // Glide

    // Facebook Stetho
    // OkHttp
    // SquareUp
    // Rx
    // Dragger
    // Realm

    // RippleButton
    compile 'com.balysv:material-ripple:1.0.2'
    compile 'com.android.support:appcompat-v7:'
    compile "com.android.support:cardview-v7:${buildTools}"
    compile "com.android.support:recyclerview-v7:${buildTools}"
    compile "com.android.support:design:${buildTools}"
    compile "com.android.support:support-v13:${buildTools}"
    compile "com.android.support:support-v4:${buildTools}"
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
    compile 'com.github.florent37:materialtextfield:1.0.7'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.splitwise:tokenautocomplete:2.0.8@aar'
    compile 'com.github.Plumillon:ChipView:1.2.0'
    compile 'com.github.clans:fab:1.6.4'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'com.google.android.gms:play-services:10.2.6'
    compile 'com.google.android.gms:play-services-location:10.2.6'
    compile 'com.google.android.gms:play-services-maps:10.2.6'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'
    compile 'com.bignerdranch.android:recyclerview-multiselect:+'
    compile 'com.facebook.stetho:stetho:1.5.0'
    compile 'com.uphyca:stetho_realm:2.0.0'
    compile 'com.lapism:searchview:4.0'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.github.arimorty:floatingsearchview:2.1.1'
    compile 'me.philio:pinentryview:1.0.6'
    compile 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.github.pchmn:MaterialChipsInput:1.0.8'


    /*----- Retrofit 2 */
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'io.reactivex.rxjava2:rxjava:2.0.2'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    compile 'com.google.dagger:dagger:2.11'
    compile 'com.google.dagger:dagger-android:2.11'
    compile 'javax.inject:javax.inject:1'
    compile 'io.realm:android-adapters:2.0.0'
    compile 'org.parceler:parceler-api:1.1.6'
    compile 'com.jakewharton:butterknife:8.5.1'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
    compile 'com.github.yalantis:ucrop:2.2.1-native'
    compile 'jp.wasabeef:picasso-transformations:2.1.2'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
    compile 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
    annotationProcessor 'org.parceler:parceler:1.1.6'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    provided 'javax.annotation:jsr250-api:1.0'
    compile 'com.mikhaellopez:circularimageview:3.0.2'          // circle image view
}


apply plugin: 'com.google.gms.google-services'

回答1:


I faced the same problem and spent 2 - 3 hours over it and I am able to find that this problem is caused by dex limit. In your app.gradle file please make following changes:

defaultConfig { 
    multiDexEnabled true 
}

And inside dependencies section add

compile 'com.android.support:multidex:1.0.2'

and the last thing you need todo is,

public class YourApplication extends MultiDexApplication {
...
}

you have to use MultiDexApplication rather than Application class. Hope some dev comes out using this solution.




回答2:


In my case I was updating the Gradle version, so I have the following lines in the dependencies:

compileOnly 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
testAnnotationProcessor "com.google.dagger:dagger-compiler:2.11"

but bassed on a tutorial, I found this lines and the problem was solved.

implementation 'com.google.dagger:dagger:2.11'
implementation 'com.google.dagger:dagger-android-support:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'



回答3:


You have to maintain your multidex library for that

add this gradle into your dependency

dependencies {
 compile 'com.android.support:multidex:1.0.1'
} 

and enable multidex in

 android {
   defaultConfig {
    ...
    minSdkVersion 21 
    targetSdkVersion 26
    multiDexEnabled true // check it carefully 
 }
...
}

Now you have to create a MyApplication class and extend it to Application

 public class MyApplication extends Application {
  @Override
  protected void Create() {
    MultiDex.install(this);
  }
}

and define it into your manifest like

 <application
        android:name=".MyApplication" >
    ...
</application>

Now build your project and try to run. I think now your problem will be solved




回答4:


In my scenario,SDK is using dagger dependencies.But I didn't include dependencies in my App.

After including dagger dependencies in app,issue is solved.



来源:https://stackoverflow.com/questions/46724468/failed-resolution-of-ldagger-internal-preconditions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!