Xamarin android app抛出ResourceNotFoundException

时间:2016-06-26 13:27:19

标签: android xaml f# xamarin.android

自从1周以来我发现了Xamarin框架,我的工作就是让Android应用程序运行起来。 iOS应用程序之前已经推出。

我必须先处理一些NuGet Packages依赖项,但现在唯一的例外是:

06-26 15:01:40.719 E/mono-rt (20038): [ERROR] FATAL UNHANDLED EXCEPTION: Android.Content.Res.Resources+NotFoundException: Resource ID #0x0
06-26 15:01:40.719 E/mono-rt (20038):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
06-26 15:01:40.719 E/mono-rt (20038):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (JniObjectReference instance, JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3340/4e275588/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083 
06-26 15:01:40.719 E/mono-rt (20038):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/3340/4e275588/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:444 
06-26 15:01:40.719 E/mono-rt (20038):   at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue* constructorParameters) [0x0000b] in /Users/builder/data/lanes/3340/4e275588/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:339 
06-26 15:01:40.719 E/mono-rt (20038):   at Android.Support.V4.App.ActionBarDrawerToggle..ctor (Android.App.Activity activity, Android.Support.V4.Widget.DrawerLayout drawerLayout, Int32 drawerImageRes, Int32 openDrawerContentDescRes, Int32 closeDrawerContentDescRes) [0x00124] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.Platform.GetNewMasterDetailToggle () [0x00030] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.Platform.UpdateMasterDetailToggle (Boolean update) [0x00075] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x000a6] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in <filename unknown>:0 
06-26 15:01:40.719 E/mono-rt (20038):   at savtime.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0001e] in D:\sources\savtime-mobile\Droid\MainActivity.cs:27 
06-26 15:01:40.719 E/mono-rt (20038):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3340/4e275588/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2426 
06-26 15:01:40.719 E/mono-rt (20038):   at (wrapper dynamic-method) System.Object:72e9ca78-aec6-45d3-82e8-45b117f59475 (intptr,intptr,intptr)
06-26 15:01:40.719 E/mono-rt (20038):   --- End of managed exception stack trace ---
06-26 15:01:40.719 E/mono-rt (20038): android.content.res.Resources$NotFoundException: Resource ID #0x0
06-26 15:01:40.719 E/mono-rt (20038):   at android.content.res.Resources.getValue(Resources.java:1243)
06-26 15:01:40.719 E/mono-rt (20038):   at android.content.res.Resources.getDrawable(Resources.java:766)
06-26 15:01:40.719 E/mono-rt (20038):   at android.content.Context.getDrawable(Context.java:402)
06-26 15:01:40.719 E/mono-rt (20038):   at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
06-26 15:01:40.719 E/mono-rt (20038):   at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
06-26 15:01:40.719 E/mono-rt (20038):   at android.support.v4.app.ActionBarDrawerToggle.<init>(ActionBarDrawerToggle.java:277)
06-26 15:01:40.719 E/mono-rt (20038):   at android.support.v4.app.ActionBarDrawerToggle.<init>(ActionBarDrawerToggle.java:229)
06-26 15:01:40.719 E/mono-rt (20038):   at md5daa929973e91d615883be6545c9acbac.MainActivity.n_onCreate(Native Method)
06-26 15:01:40.719 E/mono-rt (20038):   at md5daa929973e91d615883be6545c9acbac.MainActivity.onCreate(MainActivity.java:29)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.Activity.performCreate(Activity.java:5975)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.ActivityThread.access$800(ActivityThread.java:147)
06-26 15:01:40.719 E/mono-rt (20038):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
06-26 15:01:40.719 E/mono-rt (20038):   at android.os

我在这里看到很多帖子,这似乎是一个图标问题,但我已经检查了项目中的所有资源定义,资源名称,一切似乎都没问题。

这个问题是否可能是由错误的引用(如Xamarin Forms或Iconize)引起的?或者这只是因为缺少资源?

我已经清理了我的解决方案更新或降级我的软件包但没有任何工作..

我还必须指出我使用F#而不是C#来开发。我的观点是用XAML制作的。

4 个答案:

答案 0 :(得分:2)

终于发现了什么问题。

首先,我必须为我的所有资源文件设置&#39; AndroidResource&#39;在“构建操作”字段中(在选择资源时参见属性)

其次,我不能使用其他字符作为A到Z,0到9,以及&#39; _&#39;命名我的资源。

答案 1 :(得分:1)

这就是我解决问题的方法 -

  1. 我缺少“Xamarin.Android.Support.Animated.Vector.Drawable”NuGet包,所以我把它包含在我的android项目中。对我来说,正确的版本是23.3.0,但在你的情况下它可能不同。
  2. 删除了我的android项目的obj和bin文件夹。
  3. 重新启动visual studio。
  4. 重建

答案 2 :(得分:0)

你有没有试过这个删除内容你的C:\ Users \ YOURUSER \ AppData \ Local \ Xamarin \

Hundreds of Resource.Designer.cs build errors on latest Xamarin Forms 2.2.0.45

答案 3 :(得分:0)

我解决类似问题的方法是清理项目,重建并运行它。 是我的一位同事的好建议。