1

I'm developing a game for Android using Libgdx. A few weeks ago I started implementing some services from the Google Play Services for games. I followed this guide

and I was able to implement that services successfully.

Yesterday I opened the SDK and I decided to upload the Google Play Services package (because there was an error with AdMob) and that was the biggest errore I ever made.

I don't now what happened; initially the main error was about the AndroidManifest of the google-play-services-lib that was targeting a sdk that wasn't installed yet. I decided to install that sdk version (api 9 ...(obsolete) by the way) but now my application crashes when it starts.

I tried to reset all the stuff and repeat the steps of the guide I linked above but it doesn't work anyway.

This is the locat of the application when it starts:

12-09 09:29:41.681: I/art(20196): Late-enabling -Xcheck:jni
12-09 09:29:41.862: I/Adreno-EGL(20196): <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 09/02/15, 76f806e, Ibddc658e36
12-09 09:29:41.966: D/AndroidRuntime(20196): Shutting down VM
12-09 09:29:41.966: D/AndroidRuntime(20196): --------- beginning of crash
12-09 09:29:41.967: E/AndroidRuntime(20196): FATAL EXCEPTION: main
12-09 09:29:41.967: E/AndroidRuntime(20196): Process: com.gamestudio.gameapp.android, PID: 20196
12-09 09:29:41.967: E/AndroidRuntime(20196): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gamestudio.gameapp.android/com.gamestudio.gameapp.android.AndroidLauncher}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.example.games.basegameutils.GameHelper.onStart(android.app.Activity)' on a null object reference
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.os.Handler.dispatchMessage(Handler.java:102)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.os.Looper.loop(Looper.java:148)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread.main(ActivityThread.java:5417)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at java.lang.reflect.Method.invoke(Native Method)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-09 09:29:41.967: E/AndroidRuntime(20196): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.example.games.basegameutils.GameHelper.onStart(android.app.Activity)' on a null object reference
12-09 09:29:41.967: E/AndroidRuntime(20196):    at com.gamestudio.gameapp.android.AndroidLauncher.onStart(AndroidLauncher.java:101)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.Activity.performStart(Activity.java:6253)
12-09 09:29:41.967: E/AndroidRuntime(20196):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
12-09 09:29:41.967: E/AndroidRuntime(20196):    ... 9 more

I believe that the problem is related with the libgdx project that has been compromised. For example the R class is not correctly compiled because some of the values of my project are no longer visible from R.

Thanks for your help.

Luca

**UPDATED QUESTION **

I'm using eclipse

Luca Marzi
  • 786
  • 2
  • 8
  • 24
  • I hope you are not using eclipse. Are you? – Kush Dec 09 '15 at 15:11
  • Yes...in my defense I can only say that I started the project a bit after eclipse was no longer supported by Google... But, as I said, alla worked fine just before I updated the Google play package. – Luca Marzi Dec 09 '15 at 15:13
  • Same kind of problem bugged me a little while ago and i was also using eclipse. As long as you are not using libs like play services eclipse works fine but in your case i think move to Idea instead. – Kush Dec 09 '15 at 15:19
  • can you show your `AndroidLauncher.java` code? – fatboy Dec 10 '15 at 10:16
  • I believe that the error stands in the BaseGameUtils project that refers to an older version of the support library that is no longer present in the new game-play-services-lib. I'm trying to download an older version of the game-play-services-lib (I didn't have a copy because I'm stupid). I think the solution is in this answer: http://stackoverflow.com/a/33855328/1540840 – Luca Marzi Dec 10 '15 at 12:26

1 Answers1

0

I solved the problem. The trouble was: since I'm not developing using Android Studio there are a lot o problems related with the dependencies management. I followed this guide this guide for implementing the Game Services. Now the guide says that you have to import the BaseGameUtils and the google-play-services-lib as "library projects" and then add the reference to the BaseGameUtils project to all the projects you want.

What the guide does not say is that the BaseGameUtils project requires a specific version of the google-play-services-lib. This is not specified because if you were using Android Studio, all the dependencies would be handled by Grandle; In fact, if you take a look a the build.grandle file of the BaseGameUtils project you can see that it requires the google-play-services-lib.8.1.0.

Because I had updated the google-play-services-lib from the SDK Manager and because I didn't know the dependencies of the BaseGameUtils there were a lot of problems with references to methods that are no longer included in the new version of the google-play-services-lib.

Know I've found the older versione of the google-play-sdk-lib and I followed again the guide linked above.

I think that this is the worst way to include the BaseGameUtils lib but...since I started the project when ecplise was still supported by Android...

Thank you anyway,

Luca

Luca Marzi
  • 786
  • 2
  • 8
  • 24