我们在我们的应用程序中使用multidex很长一段时间但最近使用最新更新它在android API <19上失败,例如带有api 16的模拟器它是标准的java.lang.NoClassDefFoundError.
如果我为缺少的类定义multidexKeepProguard,例如java.lang.NoClassDefFoundError.rx.plugins.RxJavaHooks异常
-keep class rx.plugins.**{*;}
Run Code Online (Sandbox Code Playgroud)
然后它会在不同的地方失败,原因与NoClassDefFound相同
这是跑步者,应用程序和清单设置:
https://gist.github.com/originx/1890599b57b0ee3e14a85a4732301cd9
logcat的:
https://gist.github.com/originx/887f80d405334f1903b3024eb5cd1024
建立环境设置:
Android Studio 2.2.2 Build#AI-145.3360264,建于2016年10月18日JRE:1.8.0_112-release-b05 x86_64 JVM:JetJrains sro的OpenJDK 64位服务器VM
编译选项
compile 'com.android.support:multidex:1.0.1'
Run Code Online (Sandbox Code Playgroud)
构建工具信息:
classpath 'com.android.tools.build:gradle:2.2.2'
compileSdkVersion 25
buildToolsVersion '25'
defaultConfig {
applicationId "app.packagename.com"
minSdkVersion 16
targetSdkVersion 25
testInstrumentationRunner "de.payback.app.CustomAndroidJUnitRunner"
multiDexEnabled true
}
dexOptions {
jumboMode true
preDexLibraries false
javaMaxHeapSize "4g"
maxProcessCount = 8
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-debug'
signingConfig signingConfigs.debug
minifyEnabled false
shrinkResources debugShrinkResourcesEnabled
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguardRules/proguard-rules.pro', '../proguardRules/proguard-debug-rules.pro'
// multiDexKeepProguard file('../proguardRules/multidex-proguard.pro')
testProguardFiles getDefaultProguardFile('proguard-android.txt'), …Run Code Online (Sandbox Code Playgroud)