升级到Canary 6后,在API 16 AVD上运行Kotlin项目的ResourceNotFoundException
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了升级到Canary 6后,在API 16 AVD上运行Kotlin项目的ResourceNotFoundException相关的知识,希望对你有一定的参考价值。
Build:3.0 Canary 6,AI-171.4163606,201707072113,
AI-171.4163606,JRE 1.8.0_152-release-884-b01x64 JetBrains s.r.o,OS Mac OS X(x86_64)v10.12.4未知,屏幕1440x900,1920x1080,1080x1920;视网膜
tl; dr步骤重现:
使用Canary 6 android Studio创建一个全新的Android项目,并在API级别16(下面的信息)下针对Nexus 4 AVD运行它。将抛出ResourceNotFoundException(下面的堆栈跟踪)。在API级别25运行Nexus 5 AVD将成功运行预期结果。
07-12 10:56:41.671 2865-2865/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bartonstanley.testforcanary6/com.bartonstanley.testforcanary6.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f060052
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060052
at android.content.res.Resources.getValue(Resources.java:1013)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:755)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:88)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.bartonstanley.testforcanary6.MainActivity.onCreate(MainActivity.kt:9)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
******正在进行的项目中的堆栈跟踪******
07-12 08:18:47.842 13073-13073/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bartonstanley.tododoingdone/com.bartonstanley.tododoingdone.views.root.RootActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f070058
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070058
at android.content.res.Resources.getValue(Resources.java:1013)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:755)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:88)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:202)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.bartonstanley.tododoingdone.views.root.RootActivity.onCreate(RootActivity.kt:24)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
***** Nexus 4 API 16级模拟器信息******
Emulator ADB serial number
emulator-5554
Android version
4.1 (Jelly Bean) - API 16 (Rev 5)
Emulator version
26.1.2-4077558
Latest available emulator version
26.1.2-4077558 (Stable update channel)
Android SDK tools version
26.0.2
Host CPU Model
2.5 GHz Intel Core i7
Device name
hw.device.name: Nexus 4
所有视图细节
Name: Nexus_4_API_16
CPU/ABI: Google APIs Intel Atom (x86)
Path: /Users/bstanley/.android/avd/Nexus_4_API_16.avd
Target: google_apis [Google APIs] (API level 16)
Skin: nexus_4
SD Card: 100M
hw.dPad: no
hw.lcd.height: 1280
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Nexus 4
vm.heapSize: 80
skin.dynamic: yes
hw.device.manufacturer: Google
hw.lcd.width: 768
hw.gps: yes
hw.initialOrientation: Portrait
image.androidVersion.api: 16
hw.audioInput: yes
image.sysdir.1: system-images/android-16/google_apis/x86/
tag.id: google_apis
showDeviceFrame: yes
hw.camera.back: emulated
hw.mainKeys: no
AvdId: Nexus_4_API_16
hw.camera.front: emulated
hw.lcd.density: 320
avd.inidisplayname: Nexus 4 API 16
hw.gpu.mode: auto
hw.device.hash2: MD5:cd87b62509afda15361db744f4aa1ec0
hw.ramSize: 1536
hw.trackBall: no
PlayStore.enabled: false
hw.battery: yes
hw.cpu.ncore: 4
hw.sdCard: no
tag.display: Google APIs
runtime.network.latency: none
hw.keyboard: no
hw.sensors.proximity: yes
disk.dataPartition.size: 800M
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes
****** Gradle信息******
Gradle 4.1版
Android插件版本3.0.0-alpha6
模块编译Sdk Version API 26:Android 8.0(O)
模块构建工具版本25.0.3
Android SDK工具版本26.0.2
修复是在AAPT2中 - 请使用最新的构建工具(如果我没有记错,则为27.0.2),它将包含该修复。 我找到了一个解决方法:Android Studio 3.0 : canary 6 : android.content.res.Resources$NotFoundException inside Launching activity
如果任何问题仍然存在,请在Google issue tracker报告,他们将重新开放审查。
在gradle.properties
文件中添加
android.enableAapt2=false
这可能会有所帮助。检查this link
以上是关于升级到Canary 6后,在API 16 AVD上运行Kotlin项目的ResourceNotFoundException的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio 3.0 Canary 8:高级分析对所选进程不可用
Android Studio Bumblebee 2021.1.1 Canary 4 Emulator 无法在 m1 上运行