Android APK崩溃甚至gradle构建成功完成

时间:2016-10-05 06:00:19

标签: android apk dalvik

每次构建我的APK时,我都会收到以下错误; Gradle构建显示它已成功完成但在我的手机上安装APK时,它每次都崩溃

10-04 22:52:53.848 9297-9297/com.usfca.studentrecordsverify E/Trace: error opening trace file: No such file or directory (2)
10-04 22:52:53.908 9297-9297/com.usfca.studentrecordsverify E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
10-04 22:52:53.908 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve check-cast 1786 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
10-04 22:52:53.908 9297-9297/com.usfca.studentrecordsverify E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
10-04 22:52:53.908 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve const-class 1786 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve virtual method 437: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve virtual method 231: Landroid/app/Activity;.stopLockTask ()V
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.usfca.studentrecordsverify.MainActivity.access$super
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve check-cast 226 (Landroid/os/PersistableBundle;) in Lcom/usfca/studentrecordsverify/MainActivity;
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve virtual method 419: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve virtual method 154: Landroid/app/Activity;.onVisibleBehindCanceled ()V
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify W/dalvikvm: VFY: unable to resolve virtual method 158: Landroid/app/Activity;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
10-04 22:52:53.928 9297-9297/com.usfca.studentrecordsverify E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.usfca.studentrecordsverify.MainActivity.access$super

以下是SO question

2 个答案:

答案 0 :(得分:0)

android.util.ArrayMap引入了API级别19(ArrayMap)。如果您在Android 4.2.2设备上运行该代码,它将无法在您的设备上找到此类,您的应用将崩溃。

您可以使用java.util.Map代替。它不像ArrayMap那样高效,但它可以在每个Android平台上使用。

答案 1 :(得分:0)

将你的minSdkVersion改为19

defaultConfig {
   applicationId "com.usfca.studentrecordsverification"
   minSdkVersion 19
   targetSdkVersion 23
   versionCode 1
   versionName "1.0"
}

因为ArrayMap是用API级别19引入的!