play-services-oss-licenses 的主题
Theme for play-services-oss-licenses
有人成功使用新的 play-services-oss-licenses 库吗?尝试按照此处所述使用它时:
https://developers.google.com/android/guides/opensource
我得到:
Caused by: java.lang.IllegalStateException:
You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
at android.support.v7.app.AppCompatDelegateImplV9.initWindowDecorActionBar(AppCompatDelegateImplV9.java:175)
at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:145)
at android.support.v7.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:109)
at com.google.android.gms.oss.licenses.OssLicensesMenuActivity.onCreate(Unknown Source:54)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
我在我的应用程序的其余部分使用 AppCompat - 而不是为此 activity 设置主题。这是这个库中的错误吗(这是我目前的想法)——还是我做错了什么?
您需要为案例中的活动设置合适的主题。
在您的 AndroidManifest.xml
中添加这些 Activity 声明
深色
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
浅色
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.Light" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat.Light" />
如果您还没有发现这一点,问题已通过插件版本修复
com.google.android.gms:play-services-oss-licenses:16.0.0
您不需要使用 ActionBar 应用主题,因为该插件不再从应用程序中借用样式。
参考:https://developers.google.com/android/guides/releases#july_12_2018
有人成功使用新的 play-services-oss-licenses 库吗?尝试按照此处所述使用它时:
https://developers.google.com/android/guides/opensource
我得到:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:354) at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323) at android.support.v7.app.AppCompatDelegateImplV9.initWindowDecorActionBar(AppCompatDelegateImplV9.java:175) at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:145) at android.support.v7.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:109) at com.google.android.gms.oss.licenses.OssLicensesMenuActivity.onCreate(Unknown Source:54) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
我在我的应用程序的其余部分使用 AppCompat - 而不是为此 activity 设置主题。这是这个库中的错误吗(这是我目前的想法)——还是我做错了什么?
您需要为案例中的活动设置合适的主题。
在您的 AndroidManifest.xml
中添加这些 Activity 声明深色
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
浅色
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.Light" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.AppCompat.Light" />
如果您还没有发现这一点,问题已通过插件版本修复
com.google.android.gms:play-services-oss-licenses:16.0.0
您不需要使用 ActionBar 应用主题,因为该插件不再从应用程序中借用样式。
参考:https://developers.google.com/android/guides/releases#july_12_2018