点击菜单项的Android OSS许可证插件崩溃 [英] Android OSS license plugin crash on tapping menu items

查看:283
本文介绍了点击菜单项的Android OSS许可证插件崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试用 活动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 />


I've been trying out the Google APIs for Android OSS licenses tool and come across an issue.

The activity is being launched from a library module that contains the preferences aspect to my app. However, the Play Services code is crashing a lot! Has anyone seen this upon tapping the found OSS list items?

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) 

Here are the actions leading to that action;

解决方案

Just specify appropriate theme in the AndroidManifest.xml file for 2 activities OssLicensesMenuActivity and OssLicensesActivity. For example:

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

这篇关于点击菜单项的Android OSS许可证插件崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆