gpt4 book ai didi

android - API < 21 的 java.lang.VerifyError

转载 作者:行者123 更新时间:2023-11-29 15:48:47 25 4
gpt4 key购买 nike

我正在使用 MultiDex在我的应用程序中支持超过 65k 种方法。在 api 21 上它运行良好,因为它进行了 predex 构建。在 api 21 下,我的 Application 崩溃了使用此堆栈跟踪:

java.lang.VerifyError: mypackage/com/myapp/MyAppApplication
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1215)
at android.app.Instrumentation.newApplication(Instrumentation.java:990)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4537)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5322)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)

这是我的 gradle具有不同风格的文件(简化),用于在调试中使用 predex 进行编译:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "mypackage.com.myapp"
targetSdkVersion 22
versionCode Integer.parseInt(new Date().format("yyMMddHH"))
versionName "1.0"
multiDexEnabled = true
}

productFlavors {
normal {
minSdkVersion 21
}

beta {
minSdkVersion 16
versionName "1.0.0_beta"
}

prod {
minSdkVersion 16
}
}

dexOptions {
javaMaxHeapSize "4g"
}

buildTypes {
debug {
minifyEnabled false
debuggable true
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
}

这是我的 Application :

public class MyApplication extends CustomLibraryApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

在我的 list 中 <application>我有android:name=".MyApplication"

像这样的解决方案:“排除一些 google play 服务”或“扩展 MultiDexApplication”在这种情况下没有用。

最佳答案

已解决

问题是……鼓声……buildToolsVersion!

我将我的 gradle 中的 buildToolsVersion(只有 buildToolsVersion)从 22.0.1 更改为 23 rc3 (来自预览 channel 的最后一个)并且它与 api < 21 和 multidex 配合得很好。

关于android - API < 21 的 java.lang.VerifyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31587765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com