我需要在我的Android应用程序中集成Google +,我正在关注本教程http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/但是当我运行我的项目时,此消息会出现在模拟器中很遗憾,您的应用已停止这是logcat中的错误:
java.lang.runtimeexception unable to start activity componentinfo com.example.testgoogle/com.example.testgoogle.MainActivity:java.Lang.NullPointer.Exception:Null options are permitted for this API.
我不知道如何解决这个问题。我需要你的帮助。谢谢你。
以下是我的日志:
04-15 07:42:38.906: W/GooglePlayServicesUtil(1315): Google Play services is missing.
04-15 07:42:38.936: W/GooglePlayServicesUtil(1315): Google Play services is missing.
04-15 07:42:39.666: E/GooglePlayServicesUtil(1315): Internal error occurred. Please see logs for detailed information
04-15 07:42:39.846: I/Choreographer(1315): Skipped 49 frames! The application may be doing too much work on its main thread.
04-15 07:42:40.256: I/Choreographer(1315): Skipped 97 frames! The application may be doing too much work on its main thread.
04-15 07:42:44.716: E/SettingsRedirect(1315): Can't redirect to app settings for Google Play services
答案 0 :(得分:1)
使用
初始化您的api客户端// Initializing google plus api client
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API, Plus.PlusOptions.builder().build())
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
使用addApi(Plus.API, Plus.PlusOptions.builder().build())
而不是addOnConnectionFailedListener(this).addApi(Plus.API, null)
不要使用null,请使用 Plus.PlusOptions.builder()。build()
这肯定会解决您的问题