Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theme for play-services-oss-licenses

Is anyone successfully using the new play-services-oss-licenses library? When trying to use it as described here:

https://developers.google.com/android/guides/opensource

I get:

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)

I am using AppCompat in the rest of my app - and not setting a theme for this activity. Is this a bug in this library (this is what I think at the moment) - or am I doing something wrong?

like image 895
ligi Avatar asked Sep 18 '17 10:09

ligi


1 Answers

You need to set the proper Theme for the activities in your case.

Add these Activity declarations in your AndroidManifest.xml

Dark

<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" />

Dark

Light

<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" />

Light

like image 98
Ostkontentitan Avatar answered Oct 18 '22 07:10

Ostkontentitan