【发布时间】:2018-02-16 12:30:13
【问题描述】:
我已经构建了一个 android 库(各种自定义按钮)并将其上传到我的 JFrog Artifactory 现在我尝试在一个示例应用程序中测试它(非常简单的默认活动)。
同步进行得很顺利,我将 Button 添加到 xml 布局中,当我运行应用程序时它在它开始之前崩溃:
java.lang.RuntimeException: Unable to instantiate application com.mylib.library.LibApp: java.lang.ClassNotFoundException: Didn't find class "com.mylib.library.LibApp" on path: DexPathList
哪个是扩展 MultiDexApplication 的类,
当我从库项目(使用另一个本地应用程序模块和活动)运行它时,它运行良好,但是当我从服务器编译它时,它会导致此错误
经过大量谷歌搜索后,我尝试清理和重建并禁用即时运行,我尝试仅从 xml 文件中删除视图,但它仍然崩溃,看来应用程序的库有问题。
有人可以帮忙吗?所有帮助将不胜感激!
编辑:
我正在使用 MultiDex,我尝试了两种方法来实现它,扩展 Application 和扩展 MultiDexApplication,结果相同,还尝试了重建清理等等,我也尝试了 -dontobfuscate,如果它是由于 proguard 引起的
这是库 build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexEnabled true
} }}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.dagger:dagger:2.9'
compile 'com.squareup.retrofit2:retrofit:2.+'
compile 'com.squareup.retrofit2:converter-gson:2.+'
compile 'com.squareup.retrofit2:adapter-rxjava:2.+'
compile 'io.reactivex:rxjava:1.0.4'
compile "com.google.android.gms:play-services-gcm:11.0.4"
compile 'io.reactivex:rxandroid:0.24.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:23.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.evernote:android-job:1.1.8'
compile 'com.android.support:multidex:1.0.2'
}
apply plugin: 'com.google.gms.google-services'
【问题讨论】:
-
能否请您发布您的 gradle 构建文件
-
图书馆的 ?或应用的
-
我已经添加了库的构建文件,我无法添加应用程序,因为它在私有 Artifactory 上
-
好的,请添加崩溃应用的构建文件
标签: android android-library android-multidex