所以,我有一個私有庫的項目。我的lib中有一些類,我想在我的項目中使用,但是當我執行的應用程序,並嘗試訪問類它發生時異常:java.lang.ClassNotFoundException:路徑上沒有找到類:DexPathList gradle:2.1.0-alpha1
Process: chat.omni.loja, PID: 32615
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/omnichat/chat_library/_util/GaleryUtils; Caused by: java.lang.ClassNotFoundException: Didn't find class "com.omnichat.chat_library._util.GaleryUtils" on path: DexPathList[[dex file "/data/data/chat.omni.loja/files/instant-run/dex/slice-slice_9_c46d74b6abb1c51e69093e6cb8bf4a5f5e9b987f-classes.dex", dex file...
"/data/data/chat.omni.loja/files/instant-run/dex/slice-dependencies_f7fd1358be3ac9af2f69ac6f15447a76a8be062c-classes.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
這是我的庫構建gradle這個:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
ext { supportLibVersion = '23.+' }
//CircleImageView Library
compile 'de.hdodenhof:circleimageview:2.0.0'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
// SMACK Library
compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0-alpha3'
compile 'org.igniterealtime.smack:smack-tcp:4.2.0-alpha3'
//Glide Library
compile 'com.github.bumptech.glide:glide:3.6.1'
//SectionCursorAdapter Library
compile 'com.twotoasters.SectionCursorAdapter:library:1.0.+'
//Android Annotations Library
compile "org.androidannotations:androidannotations-api:$AAVersion"
//Android Annotations apt
apt "org.androidannotations:androidannotations:$AAVersion"
}
而且我的應用程序的gradle構建:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
ext { supportLibVersion = '23.+' }
//Library dependency
compile(project(':chat-library')) {
exclude group: 'com.android.support', module: 'appcompat-v7';
exclude group: 'org.androidannotations', module: "androidannotations:$AAVersion";
exclude group: 'org.androidannotations', module: "androidannotations-api:$AAVersion";
}
//Supports Library
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
// Crashlytics Kit
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true
}
//Android Annotations Library
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
//Parser Library
compile 'com.parse:parseui-widget-android:0.0.1'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
//Stetho Library
compile 'com.facebook.stetho:stetho:1.2.0'
//Material SearchView Library
compile 'com.miguelcatalan:materialsearchview:1.+'
//CropImage Library
compile 'com.soundcloud.android:android-crop:[email protected]'
}
我的配置是:
- 的Android 2.1工作室預覽1
- Android的搖籃插件 'com.android.tools.build:gradle:2.1.0-alpha1'
- 生成工具版本23.0.2
- 搖籃版本2.10
我將這個問題用了兩天時間,我嘗試了所有我發現的內容。所以可能它可能是一個新的gradle版本的錯誤,但我不能肯定這一點。還有其他人有這個問題嗎?
嘗試http://developer.android.com/intl/pt-br/tools/building/multidex.html,並在gradle-wrapper文件中,嘗試distributionUrl = https \://services.gradle.org/distributions /gradle-2.11-all.zip。可能你有非常依賴,需要multidex依賴。 –