Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin Android Theme.AppCompat错误-仅在运行时出现_Android_Xamarin_Runtime Error_Android Appcompat_Release Mode - Fatal编程技术网

Xamarin Android Theme.AppCompat错误-仅在运行时出现

Xamarin Android Theme.AppCompat错误-仅在运行时出现,android,xamarin,runtime-error,android-appcompat,release-mode,Android,Xamarin,Runtime Error,Android Appcompat,Release Mode,我有一个使用v4和v7支持库的应用程序。它在调试中运行得非常好,但现在我在发布模式下运行它,我发现一个与主题相关的错误 “此活动需要使用Theme.AppCompat主题(或子代)。” 这是我的应用程序顶部的声明,我在其中声明了一个AppCompat主题: [Activity(Label = "My App", LaunchMode = LaunchMode.SingleTask, Theme="@style/Theme.AppCompat.Light", ScreenOrientatio

我有一个使用v4和v7支持库的应用程序。它在调试中运行得非常好,但现在我在发布模式下运行它,我发现一个与主题相关的错误

“此活动需要使用Theme.AppCompat主题(或子代)。”

这是我的应用程序顶部的声明,我在其中声明了一个AppCompat主题:

   [Activity(Label = "My App", LaunchMode = LaunchMode.SingleTask, Theme="@style/Theme.AppCompat.Light", ScreenOrientation = ScreenOrientation.Portrait)]
我也在舱单中声明:

<application android:icon="@drawable/logo" android:debuggable="false" android:label="My App" android:theme="@style/Theme.AppCompat.Light">

这是我的堆栈跟踪。任何帮助都将不胜感激

libc] WARNING: generic atexit() called from legacy shared library
[monodroid-gc] GREF GC Threshold: 46800
[dalvikvm-heap] Grow heap (frag case) to 9.750MB for 803952-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 11.473MB for 1607840-byte allocation
[Adreno-EGL] <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
[OpenGLRenderer] Enabling debug mode 0
[Request] Warning: Sessionless Request needs token but missing either application ID or client token.
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
[MonoDroid] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x000e7>
[MonoDroid] at Android.App.Activity.OnCreate (Android.OS.Bundle) <0x001f3>
[MonoDroid] at FrogPoint.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x0001f>
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
[MonoDroid] at (wrapper dynamic-method) object.167c14b1-1233-456f-ab3e-1b59de9fa9bf (intptr,intptr,intptr) <0x00043>
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
[MonoDroid]     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[MonoDroid]     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[MonoDroid]     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
[MonoDroid]     at frogpoint.droid.MainActivity.n_onCreate(Native Method)
[MonoDroid]     at frogpoint.droid.MainActivity.onCreate(MainActivity.java:41)
[MonoDroid]     at android.app.Activity.performCreate(Activity.java:5231)
[MonoDroid]     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[MonoDroid]     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
[MonoDroid]     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
[MonoDroid]     at android.app.ActivityThread.access$800(ActivityThread.java:135)
[MonoDroid]     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[MonoDroid]     at android.os.Handler.dispatchMessage(Handler.java:102)
[MonoDroid]     at android.os.Looper.loop(Looper.java:136)
[MonoDroid]     at android.app.ActivityThread.main(ActivityThread.java:5001)
[MonoDroid]     at java.lang.reflect.Method.invokeNative(Native Method)
[MonoDroid]     at java.lang.reflect.Method.invoke(Method.java:515)
[MonoDroid]     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
[MonoDroid]     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
[MonoDroid]     at dalvik.system.NativeStart.main(Native Method)
[mono] 
[mono] Unhandled Exception:
[mono] Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
[mono] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
[mono] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x000e7>
[mono] at Android.App.Activity.OnCreate (Android.OS.Bundle) <0x001f3>
[mono] at FrogPoint.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x0001f>
[mono] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
[mono] at (wrapper dynamic-method) object.167c14b1-1233-456f-ab3e-1b59de9fa9bf (intptr,intptr,intptr) <0x00043>
[mono] 
[mono]   --- End of managed exception stack trace ---
[mono] java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
[mono]  at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[mono]  at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[mono]  at android.support.v7.app.ActionBarActivit
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.RuntimeException: Exception of type 'Java.Lang.RuntimeException' was thrown.
[mono-rt] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
[mono-rt] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x000e7>
[mono-rt] at Android.App.Activity.OnCreate (Android.OS.Bundle) <0x001f3>
[mono-rt] at FrogPoint.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x0001f>
[mono-rt] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
[mono-rt] at (wrapper dynamic-method) object.167c14b1-1233-456f-ab3e-1b59de9fa9bf (intptr,intptr,intptr) <0x00043>
[mono-rt] 
[mono-rt]   --- End of managed exception stack trace ---
[mono-rt] java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
[mono-rt]   at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[mono-rt]   at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[mono-rt]   at android.support.v7.app.Act
libc]警告:从旧式共享库调用泛型atexit()
[单机器人gc]GREF gc阈值:46800
[dalvikvm heap]将堆(frag大小写)增加到9.750MB,用于803952字节分配
[dalvikvm heap]将堆(frag大小写)增长到11.473MB,用于1607840字节分配
[Adreno EGL]:EGL 1.4高通公司版本:I0404C4692AFB8623F95C43AEB6D5E13ED4B30DDB日期:2013年6月11日
[OpenGLRenderer]正在启用调试模式0
[请求]警告:无会话请求需要令牌,但缺少应用程序ID或客户端令牌。
[MonoDroid]未处理的异常:
[MonoDroid]Java.Lang.RuntimeException:引发了类型为“Java.Lang.RuntimeException”的异常。
[MonoDroid]位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[MonoDroid]位于Android.Runtime.JNIEnv.CallNonvirtualVoidMethod(intptr、intptr、intptr、Android.Runtime.JValue[])
[MonoDroid]位于Android.App.Activity.OnCreate(Android.OS.Bundle)
[MonoDroid]位于FrogPoint.Droid.MainActivity.OnCreate(Android.OS.Bundle)
[MonoDroid]位于Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(intptr、intptr、intptr)
[MonoDroid]at(包装器动态方法)object.167c14b1-1233-456f-ab3e-1b59de9fa9bf(intptr,intptr,intptr)
[MonoDroid]——托管异常堆栈跟踪的结束---
[MonoDroid]java.lang.IllegalStateException:此活动需要使用Theme.AppCompat主题(或子代)。
[MonoDroid]位于android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[MonoDroid]位于android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[MonoDroid]位于android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
[MonoDroid]位于frogpoint.droid.MainActivity.n_onCreate(本机方法)
[MonoDroid]位于frogpoint.droid.MainActivity.onCreate(MainActivity.java:41)
[MonoDroid]位于android.app.Activity.performCreate(Activity.java:5231)
[MonoDroid]位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[MonoDroid]位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
[MonoDroid]位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
[MonoDroid]位于android.app.ActivityThread.access$800(ActivityThread.java:135)
[MonoDroid]位于android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[MonoDroid]位于android.os.Handler.dispatchMessage(Handler.java:102)
[MonoDroid]位于android.os.Looper.loop(Looper.java:136)
[MonoDroid]位于android.app.ActivityThread.main(ActivityThread.java:5001)
[MonoDroid]位于java.lang.reflect.Method.Invokenactive(本机方法)
[MonoDroid]位于java.lang.reflect.Method.invoke(Method.java:515)
[MonoDroid]位于com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
[MonoDroid]位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
位于dalvik.system.NativeStart.main的[单机器人](本机方法)
[单声道]
[mono]未处理的异常:
[mono]Java.Lang.RuntimeException:引发了类型为“Java.Lang.RuntimeException”的异常。
[mono]位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[mono]位于Android.Runtime.JNIEnv.CallNonvirtualVoidMethod(intptr、intptr、intptr、Android.Runtime.JValue[])
[mono]位于Android.App.Activity.OnCreate(Android.OS.Bundle)
[mono]位于FrogPoint.Droid.MainActivity.OnCreate(Android.OS.Bundle)
[mono]位于Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(intptr、intptr、intptr)
[mono]at(包装器动态方法)object.167c14b1-1233-456f-ab3e-1b59de9fa9bf(intptr、intptr、intptr)
[单声道]
[mono]——托管异常堆栈跟踪的结束---
[mono]java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或子代)。
[mono]位于android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[mono]位于android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[mono]位于android.support.v7.app.ActionBarActivit
[mono rt][错误]引发了严重的未处理异常:Java.Lang.RuntimeException:引发了类型为“Java.Lang.RuntimeException”的异常。
[mono rt]位于System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在Android.Runtime.JNIEnv.CallNonvirtualVoidMethod(intptr、intptr、intptr、Android.Runtime.JValue[])中使用[mono rt]
[mono rt]位于Android.App.Activity.OnCreate(Android.OS.Bundle)
[mono rt]位于FrogPoint.Droid.MainActivity.OnCreate(Android.OS.Bundle)
[mono-rt]位于Android.App.Activity.n_OnCreate_Landroid_os_Bundle(intptr、intptr、intptr)
[mono rt]at(包装器动态方法)object.167c14b1-1233-456f-ab3e-1b59de9fa9bf(intptr、intptr、intptr)
[单色rt]
[mono rt]——托管异常堆栈跟踪的结束---
[mono rt]java.lang.IllegalStateException:此活动需要使用Theme.AppCompat主题(或子代)。
[mono rt]位于android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
[mono rt]位于android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
[mono rt]位于android.support.v7.app.Act

正如我们在评论中讨论的那样。如果您的目标是Android 4.3及以上版本,则无需使用Support v7。支持包旨在为那些不支持新API级别中的内容的API级别提供向后兼容性。比如ActionBar,Fragments等等,但是自从API 13,Fragments
android:theme="@style/Theme.AppCompat.NoActionBar"
<resources>
  <style name="MyTheme.Base" parent="Theme.AppCompat.Light">
  </style>
  <style name="MyTheme" parent="MyTheme.Base">
  </style>
  <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/pngfilename</item>
    <item name="android:windowNoTitle">true</item>  
    <item name="android:windowFullscreen">false</item>  
    <item name="android:windowContentOverlay">@null</item>  
    <item name="android:windowActionBar">true</item>  
  </style>
</resources>