无法加载布局,活动失败:setContentView "失踪" resource是布局文件夹下找到的活动布局 Activity扩展了FragmentActivity 设备:HTC M9运行棉花糖
堆栈跟踪:
Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{MyActivty}:
android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2836)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivty.onCreate(MyActivty.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.io.FileNotFoundException: Share with %s
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:508)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2818)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivty.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
12-24 17:43:16.037 10054-10054/com.deepinstinct.android.dev.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.deepinstinct.android.dev.debug, PID: 10054
java.lang.RuntimeException: Unable to start activity ComponentInfo{packageName/packageName.MyActivity}:
android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2836)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.io.FileNotFoundException: Share with %s
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:508)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2818)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
我从未见过这个错误:文件与xml类型布局资源中的%s共享 我该如何解决这个问题?
答案 0 :(得分:1)
解决了它:
我通过反射将一个安卓库加载到我的项目中。堆栈跟踪中的指定资源:0x7f0a001d(我的布局ID)是加载库中appcompat组件的资源ID,并且资源存在冲突。
蛮力解决方案: 为我的布局创建一个唯一的布局ID,它不会与加载的库(通过复制粘贴原始布局)发生冲突。显然不是最好的解决方案对我有用的实际解决方案: 加载的库是所有代码,并且没有本机android功能,所以我从.gradle中删除了appcompat v7支持库,使冲突的资源消失