当我将构建配置从调试更改为发布时,我在VS 2017中的Xamarin中遇到以下异常:
07-07 14:34:49.820 D/AccessibilityManager(10619): setStateLocked: wasEnabled = false, mIsEnabled = false, wasTouchExplorationEnabled = false, mIsTouchExplorationEnabled = false, wasHighTextContrastEnabled = false, mIsHighTextContrastEnabled = false
07-07 14:34:49.820 D/AccessibilityManager(10619): java.lang.Throwable: setStateLocked
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.accessibility.AccessibilityManager.setStateLocked(AccessibilityManager.java:553)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.accessibility.AccessibilityManager.<init>(AccessibilityManager.java:226)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.View.setFlags(View.java:9843)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.ViewGroup.initViewGroup(ViewGroup.java:536)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.ViewGroup.<init>(ViewGroup.java:525)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.ViewGroup.<init>(ViewGroup.java:520)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.support.v7.widget.Toolbar.<init>(Toolbar.java:200)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
07-07 14:34:49.820 D/AccessibilityManager(10619): at java.lang.reflect.Constructor.newInstance(Native Method)
07-07 14:34:49.820 D/AccessibilityManager(10619): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.LayoutInflater.createView(LayoutInflater.java:607)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
07-07 14:34:49.820 D/AccessibilityManager(10619): at md5fcb90111a512f6bdf8650a2bd92e7238.MainActivity.n_onCreate(Native Method)
07-07 14:34:49.820 D/AccessibilityManager(10619): at md5fcb90111a512f6bdf8650a2bd92e7238.MainActivity.onCreate(MainActivity.java:31)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.Activity.performCreate(Activity.java:6092)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.ActivityThread.access$800(ActivityThread.java:178)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.os.Handler.dispatchMessage(Handler.java:111)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.os.Looper.loop(Looper.java:194)
07-07 14:34:49.820 D/AccessibilityManager(10619): at android.app.ActivityThread.main(ActivityThread.java:5631)
07-07 14:34:49.820 D/AccessibilityManager(10619): at java.lang.reflect.Method.invoke(Native Method)
07-07 14:34:49.820 D/AccessibilityManager(10619): at java.lang.reflect.Method.invoke(Method.java:372)
07-07 14:34:49.820 D/AccessibilityManager(10619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
07-07 14:34:49.820 D/AccessibilityManager(10619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
07-07 14:34:49.831 W/art (10619): Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
我从应用程序中看到的只是一个白色屏幕。一旦我将配置更改回Debug,一切正常。
前几天我在GUI上做了很多改变之前,一切都运转良好。问题是我不知道异常消息是什么意思。什么是StateLocked?
根据评论的建议,我在下面添加了我的代码的更多部分:
MainActivity.cs:
[Activity(Label = "enio.TrackR", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
protected override void OnStart()
{
base.OnStart();
StartService(new Intent(this, typeof(LocationService)));
}
}
答案 0 :(得分:0)
我相信你需要改变
StartService(new Intent(this, typeof(LocationService)));
要
Intent serviceIntent = new Intent(this, typeof(LocationActivity));
context.StartActivity(serviceIntent);
答案 1 :(得分:0)
有人给了我建议,改变Android项目属性中的链接选项来自&#34; Sdk和用户组件&#34;到&#34; Sdk Assemblies Only&#34;。这解决了这个问题,我可以启动应用程序并将其部署到Playstore。