https://developer.android.com/studio/build/multidex.html#about
为了解决分包NoClassDefFoundError,一步步按照官方文档说明设置,
android {
buildTypes {
release {
multiDexKeepFile file 'multidex-config.txt'
...
}
}
}
代码加上,再编译
Error:(40, 0) Could not get unknown property 'file' for BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.
<a href="openFile:D:\Androidproject\zzl\app\build.gradle">Open File</a>
WTF!!! 不会是gradle版本的问题吧,然后去升级,没有效果...后来google,正确的写法是
multiDexKeepProguard file('multdex-proguard.pro')
来自官方的坑。