首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Xamarin Android.FormsAppCompatActivity NullReferenceException启动时

Xamarin Android.FormsAppCompatActivity NullReferenceException启动时
EN

Stack Overflow用户
提问于 2016-11-13 03:09:22
回答 1查看 1.2K关注 0票数 6

为了找到这个问题,我尽可能地精简了我的应用程序。尽管如此,它看起来:

代码语言:javascript
复制
11-12 15:56:27.908 I/MonoDroid(17629): System.NullReferenceException: Object reference not set to an instance of an object.
11-12 15:56:27.908 I/MonoDroid(17629):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage (Xamarin.Forms.Page page, System.Int32 width, System.Int32 height) [0x0005d] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:279 
11-12 15:56:27.908 I/MonoDroid(17629):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00003] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:196 
11-12 15:56:27.908 I/MonoDroid(17629):   at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0000e] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:73 
11-12 15:56:27.908 I/MonoDroid(17629):   at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00009] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.ViewGroup.cs:3427 
11-12 15:56:27.908 I/MonoDroid(17629):   at (wrapper dynamic-method) System.Object:784a0fc1-dc7c-42ec-831f-0701fd382e8e (intptr,intptr,bool,int,int,int,int)
11-12 15:56:27.925 W/art     (17629): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable

这是我的Android活动

代码语言:javascript
复制
[Activity(Label = "Bol",Icon = "@drawable/icon",MainLauncher = true,Theme = "@style/MyTheme.Splash", NoHistory = true)]
public class MainActivity : FormsAppCompatActivity

对于闪屏,我有以下值/styles.xml

代码语言:javascript
复制
<resources>
 <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
  <item name="android:windowBackground">@drawable/splash_screen</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:windowActionBar">false</item>
  <item name="android:windowFullscreen">true</item>
  <item name="android:actionBarSize">0dp</item>
 </style>
</resources>

和drawable/splash_screen.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#000000"/>
</item>
<item>
<bitmap
    android:src="@drawable/icon"
    android:tileMode="disabled"
    android:gravity="center"/>
</item>
</layer-list>

和Xamarin (棱镜)应用程序

代码语言:javascript
复制
public class App : PrismApplication
{
    public App(IPlatformInitializer initializer = null) : base(initializer) { }

    protected override void OnInitialized()
    {
        Logger = Container.Resolve(typeof(ILogger), null, new CompositeResolverOverride()) as ILoggerFacade;
        var navigationPage = "NavigationPage/MainMenu";
        NavigationService.NavigateAsync(navigationPage);
    }
}

MainMenu只是一个空的ContentPage。

我没有看到任何关于利兹在Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage期间对NullReference做什么的提示

EN

回答 1

Stack Overflow用户

发布于 2020-03-23 15:00:43

MainAcitivity,将NoHistory改为false帮助了我-在华为设备上发生了几次崩溃,这些都是在点击主页按钮时发生的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40566601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档