I want to create an Android application and using Google People Api. I followed all the steps on this tutorial: https://developers.google.com/people/v1/getting-started.
So I created a new project in Google Api Console, get the client id and client secret for a web application, set the consent screen oauth. Finally I tried to run the google code that use can see in the above link, but I get an Exception on creating "GoogleTokenResponse".
I post the exception even if I don't find it useful:
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.access$900(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.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
Has anyone had the same? Is there any working example?
I need to use "Google Button Sign-in"?
I think you can try and use the following example:
https://github.com/sdivakarrajesh/Google-Drive-Java-API
It's for Google Drive Api but you can use the code for permission and then change the scopes.
Related
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 5 years ago.
I'm developing an Android application with Android Studio and since today I can no longer run the app because when Android Studio installs the apk on my device, the package installer crashes with the following message "Unfortunately, package installer has stopped". The strange thing is that when I run the application I can see for a second the main activity and its components but then everything crashes.
This is the exception:
10-15 22:16:48.185 1793-1793/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.packageinstaller, PID: 1793
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity}: java.lang.NullPointerException: Attempt to get length of null array
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.computePermissionGrantState(GrantPermissionsActivity.java:312)
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.updateDefaultResults(GrantPermissionsActivity.java:362)
at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.onCreate(GrantPermissionsActivity.java:105)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Thank you very much in advance
You have an issue with "granted permissions on runtime", basically you must grant permissions to use specific functionalities.
Have a look here: https://developer.android.com/training/permis
Have a look at you manifest and check which of the "user-permissions" are required to check in runtime, if you have not user-permissions added, then now is the time https://developer.android.com/guide/topics/manifest/uses-permission-element.html.
Then use the code provided in the first link after to check runtime permissions.
Remember: ask permissions on runtime is required for Android 6.0 (API level 23) and above. On lower SDK (<=22), is enough adding the "user-permissions" into the manifest.
I have developed an Application for a device Manufacturer which will be Pre loaded as System Application into the Device. The Device Manufacturer has Pre loaded the system application and it is available in the system image of the device. Now the requirement from the client is to update this system Application through play store in the similar way Google Play Services is updated.
I have uploaded a higher version of Application on the Google play store and once I update the App , initially the App crashes and the update is not reflected on the device until the device is rebooted. But the Preloaded applications like Google Maps, Google Play Services gets updated as soon as it is downloaded from the play store.
I have followed the steps mentioned on Google Support for updating System App :Updating System App through Play Store (Scroll to last of the page)
Please Let me know if some one has any idea about this.
The crash logs that I am getting are as follows :
06-21 18:40:40.748 2577-2577/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.harman.panasonicaicollection, PID: 2577
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.harman.panasonicaicollection/com.harman.panasonicaicollection.activities.MainDashBoardActivity}: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.access$900(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5429)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:475)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:277)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.harman.panasonicaicollection.activities.MainDashBoardActivity.onCreate(MainDashBoardActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6311)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2479)
at android.app.ActivityThread.access$900(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5429)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I am integrating ChromeCast in my app which has OOYALA. So the problem I am facing is OOYALA has its own cast SDK and its initialization is done at application level where we pass our cast app id (registered on Google Cast console). As soon as I change OOYALA's sample ID and I try to play a video an exception occurs. Here is the exception:
com.ooyala.android.OoyalaException: cast media load failed with code 2100
at com.ooyala.android.castsdk.CastManager$VideoCastListener.onMediaLoadResult(CastManager.java:87)
at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager$3.onResult(VideoCastManager.java:1037)
at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager$3.onResult(VideoCastManager.java:1032)
at com.google.android.gms.internal.zzly$zza.zzb(Unknown Source)
at com.google.android.gms.internal.zzly$zza.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
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:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
I have setup AerisDemo android application found on this link in android studio. I am using google play services latest version. When I run the app, it works perfectly until I click on "Interactive Maps" option, the app crashes. Below is the error:
java.lang.NullPointerException: Attempt to invoke virtual method 'com.hamweather.aeris.tiles.AerisTile com.hamweather.aeris.maps.AerisMapOptions.getTile()' on a null object reference
at com.example.fragment.MapFragment.initMap(MapFragment.java:166)
at com.example.fragment.MapFragment.onActivityCreated(MapFragment.java:102)
at android.app.Fragment.performActivityCreated(Fragment.java:2072)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:912)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:846)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1473)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5528)
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:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Can anyone help me solve this issue?
Thanks.
I've implemented Google App Invites in my app using this guide : https://developers.google.com/app-invites/android/guides/app
I can send the invite and it is received by the person I invited. The problem is the install button in the email crashes Google Play Services when the app is already installed. It the shows me following error.
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.content.Intent.addFlags(int)' on a null object reference
at com.google.android.gms.appinvite.notification.a.a(SourceFile:219)
at com.google.android.gms.appinvite.a.onPostExecute(SourceFile:29)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Does anybody have a clue to what I'm doing wrong?
The app must have a main activity that has a category of either CATEGORY_INFO or CATEGORY_LAUNCHER.