Reputation: 21
I am having MvvmCross
Xamarin Forms project. I right click on Android project and migarted to AndroidX. Now while I run I get error. Please help
Android.Content.Res.Resources+NotFoundException: 'Resource ID #0x7f0b0047'
[Activity(Label = "MyApp", Icon = "@drawable/icon", MainLauncher = false, ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : MvxFormsAppCompatActivity
{
public static MainActivity Instanace;
protected override void OnCreate(Bundle bundle)
{
Instanace = this;
Xamarin.Essentials.Platform.Init(this, bundle);
base.Window.RequestFeature(WindowFeatures.ActionBar);
// Name of the MainActivity theme you had there before.
// Or you can use global::Android.Resource.Style.ThemeHoloLight
//base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(bundle); *------------------Here I get error*
TabLayoutResource = Resource.Layout.tabs;
ToolbarResource = Resource.Layout.toolbar;
}
Upvotes: 2
Views: 548
Reputation: 5048
I was able to overcome this error in my app. It was failing in FormsAppCompatActivity.OnCreate(Bundle savedInstanceState, ActivationFlags flags)
, when ToolbarResource
was not set. This caused the following code to run: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs#L235
It turns out, that inflating Resource.Layout.Toolbar
is problematic and causes the error you described.
The workaround is to assign the ToolbarResource
(specifying a resource from your Resource.Layout
in your MainActivity
before base.OnCreate()
is called.
Upvotes: 1
Reputation: 3986
Try Clean/Rebuild solution, sometimes the Resource.Designer.cs is not regenerated for some reason.
Upvotes: 0