无法使用Dexter构建项目

时间:2016-12-22 14:38:18

标签: gradle build classnotfoundexception

我切换到另一个项目,当我回来时,我发现我以前的项目不起作用。请注意,我没有更改代码。 这是例外:

12-22 09:25:03.579 19103-19103/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.mysvit.youq, PID: 19103
                                                   java.lang.NoClassDefFoundError: Failed resolution of: Lcom/karumi/dexter/Dexter;
                                                       at com.mysvit.youq.YouQApplication.onCreate(YouQApplication.java:73)
                                                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
                                                       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 "com.karumi.dexter.Dexter" on path: DexPathList[[zip file "/data/app/com.mysvit.youq-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mysvit.youq-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.mysvit.youq.YouQApplication.onCreate(YouQApplication.java:73) 
                                                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012) 
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553) 
                                                       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: com.karumi.dexter.Dexter
                                                       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)
                                                            ... 13 more
                                                    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

这是在Application类中的位置,它崩溃了:

 @Override
    public void onCreate() {
        super.onCreate()
        Dexter.initialize(getApplicationContext());
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(this);
        Fabric.with(this, new Crashlytics());
    }

1 个答案:

答案 0 :(得分:0)

这是一个gradle问题而不是库问题,看来你的JVM没有正确读取你的gradle构建。!

尝试此解决方法:

repositories {
      //..
      maven { url 'http://guardian.github.com/maven/repo-releases' }

    }

dependencies {
      //..
    compile 'com.gu:option:1.3'
}