我正在开发一个 Android 库,用于在我的应用程序中模块化一些工作,并使用 Retrofit 消费一些 Web API。
当我编译并在同一 Android Studio 项目中的示例应用程序中使用它(编译库模块)时,一切正常,但当我从构件中使用该库时,出现了错误 在路径上未找到类....
我的 gradle.build 文件包含以下内容
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.+"
testCompile "org.hamcrest:hamcrest-core:1.3"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile 'org.robolectric:robolectric:3.0'
}
我尝试了Retrofit和Retrofit2,但在实现库时我的应用程序仍然崩溃了。
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.logging.HttpLoggingInterceptor" on path: DexPathList[[dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-support-annotations-23.3.0_471cb7629dd1bd2eaf19897f0bfa2e292d59a1a2-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-mx.segundamano.android-payments-library-0.1-SNAPSHOT_afd67b66a26310987e26f412f53082c415795025-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-internal_impl-23.3.0_ffb5ab0b136af54fef26d794f3208310ca6ef941-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.3.0_2834a08897c09d9f4cf6a603048125bd86044324-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-com.android.support-support-v4-23.3.0_0fe06b17a4b2ae866e5066f3ea5bc8d596bd609e-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-com.android.support-multidex-1.0.1_9e5a739896463403b4d643ff254bf74dcc98371f-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.3.0_eba794855dfef17238864c6651afded84f82cf47-classes.dex", dex file "/data/data/mx.segundamano.paymentsdemo/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.3.0_41e987bda5b0c3ecdbb65ba4dfa7c24496152077-classes.dex"],nativeLibraryDirectories=[/data/app/mx.segundamano.paymentsdemo-1/lib/arm64, /vendor/lib64, /system/lib64]]
05-11 11:40:03.737 4279 4279 E AndroidRuntime: 在 dalvik.system.BaseDexClassLoader 中找到类(BaseDexClassLoader.j)