gpt4 book ai didi

android - 应用仅在 Android 5.0 上崩溃并出现 VerifyError

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:15:19 26 4
gpt4 key购买 nike

我的应用程序在除 5.0 以外的所有版本上都运行良好。在那个版本上,每个有一个包传递给它的 Activity 都会崩溃..

这是日志:

05-09 01:37:43.733 6371-6371/com.pttest.com.pockettankstips E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pttest.com.pockettankstips, PID: 6371
java.lang.VerifyError: Rejecting class com.pttest.com.pockettankstips.compare because it failed compile-time verification (declaration of 'com.pttest.com.pockettankstips.compare' appears in /data/data/com.pttest.com.pockettankstips/files/instant-run/dex/slice-slice_9-classes.dex)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

这是我打开 Activity 的代码:

Intent co = new Intent("com.pttest.com.pockettankstips.compare");
Bundle compare = new Bundle();
compare.putString("index", "3 Shot");
co.putExtras(compare);
startActivity(co);
Toast.makeText(getBaseContext(), "Select Second Weapon to Compare!", Toast.LENGTH_LONG).show();
break;

以及我如何在我即将打开的 Activity 中接收 Bundle..

c1 = (Spinner) findViewById(R.id.cspin1);
c2 = (Spinner) findViewById(R.id.cspin2);
c1.setAdapter(new MyAdapter(this, R.layout.spinada, weapon));
c2.setAdapter(new MyAdapter1(this, R.layout.spinada, weapon1));
c1.setOnItemSelectedListener(this);
c2.setOnItemSelectedListener(this);
Bundle compare = getIntent().getExtras();
String compone = compare.getString("index", "3 Shot");
String[] weaponone = getResources().getStringArray(R.array.weapalpha);
x = Arrays.asList(weaponone).indexOf(compone);
c1.setSelection(x);

在我尝试在 Bundle 中发送 int 的 Activities 中它工作正常,但是当我尝试发送 String 时它崩溃了..

最佳答案

我以前的项目有一个错误,如下所示,我解决了看到答案。

java.lang.VerifyError: Rejecting class com.harshad.syncV4.android.module.ModuleTest because it failed compile-time verification (declaration of 'com.harshad.syncV4.android.module.ModuleTest' appears in /data/app/com.harshad.syncV4.android-1/base.apk)

注意事项:

此错误发生在 Android 操作系统版本 5.0.1 中。

我的代码:

我在我的代码中这样做。

try {
synchronized (this) {
this.wait(100);
}
} catch (InterruptedException e) {
/* Exception message can be captured here */
}

try/catch block 内的同步块(synchronized block)

当我在同步块(synchronized block)中设置 try/catch 时 - 应用程序开始照常工作。顺便说一下,在 Android OS 5.0.1 之前,这种方法没有问题。我认为这是因为新的 ART 编译器。

正确的方式:

synchronized (this) {
try {
this.wait(testActionItem.getDelay());
} catch (InterruptedException e) {
/* Exception message can be captured here */
}
}

关于android - 应用仅在 Android 5.0 上崩溃并出现 VerifyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37107731/

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