点击菜单项时,Android OSS许可插件崩溃

时间:2017-09-08 21:37:49

标签: android google-play-services gms-licenses-plugin

我一直在试用Google APIs for Android OSS licenses工具并遇到问题。

正在从包含首选项方面的库模块启动活动到我的应用程序。但是,Play服务代码崩溃了很多!有没有人在点击找到的OSS列表项时看到这个?

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oceanlife/com.google.android.gms.oss.licenses.OssLicensesActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference
    at com.google.android.gms.oss.licenses.OssLicensesActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:6679)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6119) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

以下是导致该行动的行动;

replication

2 个答案:

答案 0 :(得分:38)

只需在AndroidManifest.xml文件中为2个活动OssLicensesMenuActivity和OssLicensesActivity指定适当的主题。例如:

<activity android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
    android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

<activity android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
    android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

答案 1 :(得分:1)

应用标记

<application
        android:theme="@style/AppTheme">

application/>

styles.xml

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
    </style>

我希望ActionBar需要设置标题的活动

Working like this