添加@aar库后,Lollipop设备上出现NoClassDefFound错误

时间:2016-10-25 18:39:31

标签: android performance android-layout android-gradle aar

我在我的android项目中添加了Twitter SDK

compile('com.twitter.sdk.android:twitter:2.1.1@aar') {
    transitive = true;
}

添加此内容后,当我点击Video时,它会开始向我显示以下错误消息。虽然VideoTwitter没有直接关联。

这里可能存在一些相互矛盾的东西,或者可能是我可以进入的其他原因;事情是它只在Lollipop

上崩溃了
 FATAL EXCEPTION: main
 Process: com.myapp.app, PID: 26669
  java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/vr/sdk/widgets/video/VrVideoView$Options;

   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.vr.sdk.widgets.video.VrVideoView$Options" on path: DexPathList[[zip file "/data/app/com.myapp.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.app-1/lib/arm, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

的build.gradle

    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {

        applicationId 'com.myapp.app'
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 10
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86"
        }
    }
    dexOptions {
        javaMaxHeapSize "4g" //specify the heap size for the dex process
    }
    lintOptions {
        abortOnError false
    }

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

    productFlavors {
    }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
   compile 'com.github.michaelye.easydialog:easydialog:1.4'
    compile 'com.google.android.gms:play-services:9.0.1'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.twotoasters.servos:util:1.0.0'
    compile 'com.twotoasters.servos:util-otto:1.0.0'
    compile 'se.emilsjolander:stickylistheaders:2.7.0'
    compile 'com.google.zxing:core:3.2.1'
    compile(name: 'android-async-http-1.4.9', ext: 'jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') {
        transitive = true;
    }

    compile('com.twitter.sdk.android:twitter:2.1.1@aar') {
        transitive = true;
    }

1 个答案:

答案 0 :(得分:0)

  1. 您可以在Twitter之前删除此compile 'com.google.android.gms:play-services-ads:7.5.0',因为您已在上面添加

  2. google play服务版需要相同版本

    compile 'com.google.android.gms:play-services-maps:9.0.1' compile 'com.google.android.gms:play-services-analytics:9.0.1' compile 'com.google.android.gms:play-services-location:9.0.1' compile 'com.google.android.gms:play-services-ads:9.0.1'

  3. 清洁项目