自从 1 周以来,我发现了 Xamarin 框架,我的工作是让 Android 应用程序运行。 iOS应用程序之前已经推出了。
我必须首先处理一些 NuGet 包依赖项,但现在我得到的唯一例外是:
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 做出的。
终于找到问题所在了。
首先,我必须在“构建操作”字段中为所有资源文件设置“AndroidResource”(选择资源时请参阅属性)
其次,我不能使用 A 到 Z、0 到 9 和“_”等其他字符来命名我的资源。
这就是我为解决问题所做的 -
我解决类似问题的方法是清理项目、重建并运行它。 这是我的一位同事给我的一个很好的建议。
您是否尝试过删除 C:\Users\YOURUSER\AppData\Local\Xamarin\ 中的内容
当我重命名、插入或替换可绘制路径中的任何文件时,这种情况总是发生在我身上。
每当我做这样的事情时,我都会遵循以下步骤: