Android 使用 Google 设置凭据 API
Android setting up credential using Google API
我想创建一个 Android 应用程序并使用 Google 人 Api。我遵循了本教程中的所有步骤:https://developers.google.com/people/v1/getting-started.
所以我在 Google Api 控制台中创建了一个新项目,获取 Web 应用程序的客户端 ID 和客户端密码,设置同意屏幕 oauth。最后我尝试 运行 使用的 google 代码可以在上面 link 中看到,但是我在创建 "GoogleTokenResponse".
时遇到异常
我 post 异常,即使我觉得它没有用:
Process: simone.biliato.testpeopleapi, PID: 13067
java.lang.RuntimeException: Unable to start activity ComponentInfo{simone.biliato.testpeopleapi/simone.biliato.testpeopleapi.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NullPointerException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)
at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127)
at com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest.setCode(AuthorizationCodeTokenRequest.java:147)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.setCode(GoogleAuthorizationCodeTokenRequest.java:147)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.setCode(GoogleAuthorizationCodeTokenRequest.java:79)
at com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest.<init>(AuthorizationCodeTokenRequest.java:103)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.<init>(GoogleAuthorizationCodeTokenRequest.java:111)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.<init>(GoogleAuthorizationCodeTokenRequest.java:92)
at simone.biliato.testpeopleapi.MainActivity.setUp(MainActivity.java:63)
at simone.biliato.testpeopleapi.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
有没有人有同样的?有没有工作的例子?
我需要使用 "Google Button Sign-in"?
我想您可以尝试使用以下示例:
https://github.com/sdivakarrajesh/Google-Drive-Java-API
它适用于 Google 驱动器 Api,但您可以使用代码获得许可,然后更改范围。
我想创建一个 Android 应用程序并使用 Google 人 Api。我遵循了本教程中的所有步骤:https://developers.google.com/people/v1/getting-started.
所以我在 Google Api 控制台中创建了一个新项目,获取 Web 应用程序的客户端 ID 和客户端密码,设置同意屏幕 oauth。最后我尝试 运行 使用的 google 代码可以在上面 link 中看到,但是我在创建 "GoogleTokenResponse".
时遇到异常我 post 异常,即使我觉得它没有用:
Process: simone.biliato.testpeopleapi, PID: 13067
java.lang.RuntimeException: Unable to start activity ComponentInfo{simone.biliato.testpeopleapi/simone.biliato.testpeopleapi.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NullPointerException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)
at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127)
at com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest.setCode(AuthorizationCodeTokenRequest.java:147)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.setCode(GoogleAuthorizationCodeTokenRequest.java:147)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.setCode(GoogleAuthorizationCodeTokenRequest.java:79)
at com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest.<init>(AuthorizationCodeTokenRequest.java:103)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.<init>(GoogleAuthorizationCodeTokenRequest.java:111)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.<init>(GoogleAuthorizationCodeTokenRequest.java:92)
at simone.biliato.testpeopleapi.MainActivity.setUp(MainActivity.java:63)
at simone.biliato.testpeopleapi.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
有没有人有同样的?有没有工作的例子? 我需要使用 "Google Button Sign-in"?
我想您可以尝试使用以下示例: https://github.com/sdivakarrajesh/Google-Drive-Java-API
它适用于 Google 驱动器 Api,但您可以使用代码获得许可,然后更改范围。