Android App crash with BaseGameActivity - android

So, somewhat hard to ask.
I wanna use the google play game service to access a leaderboard for my game.
I tried to use BaseGameActivity like it is shown here Accessing the Games APIs
Tried a few things, did some search but cannot figure out the problem. My App crashes when the BaseGameActivity is started.
Log error shows:
03-10 17:44:54.071: E/AndroidRuntime(31435): FATAL EXCEPTION: main
03-10 17:44:54.071: E/AndroidRuntime(31435): java.lang.IllegalStateException: A
fatal developer error has occurred. Check the logs for further information.
03-10 17:44:54.071: E/AndroidRuntime(31435): at com.google.android.gms.internal.dw$h.b(Unknown Source)
03-10 17:44:54.071: E/AndroidRuntime(31435): at com.google.android.gms.internal.dw$h.b(Unknown Source)
03-10 17:44:54.071: E/AndroidRuntime(31435): at com.google.android.gms.internal.dw$b.bR(Unknown Source)
03-10 17:44:54.071: E/AndroidRuntime(31435): at com.google.android.gms.internal.dw$a.handleMessage(Unknown Source)
Console shows:
[2014-03-10 17:47:18 - BaseGameUtils] Could not find BaseGameUtils.apk!
Answer:
I had to do two metadata entrys about the appid in the manifest.
The Log without filters listed the corresponding errors
The two entries were
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data
android:name="com.google.android.gms.appstate.APP_ID"
android:value="#string/app_id" />
only one of these entries were mentioned in the tutorial.

I've just finished putting up leaderboards and it was a pain, but I did it and it works. Here's a long list of suggestions that may directly or indirectly help you. I use Eclipse.
For Google Play API, minimum SDK is 9 so put this in your manifest on it's own line:
< uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19"/>
//whatever target you want
Import the BaseGameUtils project to your workspace. You do not have to modify any of this code.
Import google-play-services_lib. This is in your sdk folder. My sdk folder is next to my eclipse folder. Anyways this is in: sdk/extras/google/google_play_services/libproject/google-play-services_lib. You do not have to modify any of this code.
Right Click on YourProject in the package explorer tab (normally on the left side of eclipse with all of your project folders). Then click on Properties (Alt+Enter). Then click on Android. On the bottom part of the Android page, should be "Library." Click the add button and add BaseGameUtils and google-play-services_lib. Do not click "Is Library".
Ensure all of the android-support-v4.jar files in all the relevant projects are using the same up-to-date version. You can update your support file by right clicking your project in the "package explorer" tab and going to ->Android Tools->Add Support Library. Then you accept and update.
You can further check to see if all of the projects listed have this updated jar by right clicking your project and going to properties. Then click on Java Build Path and then Click on the libraries tab. You should see the support jar listed. If not, you can add the jar, where-ever it is located in the project. If you do not do this, you may have something called JAR MIXMATCH. Of course, you will see the exact problem in your console so this is easy to fix and diagnose.
Your manifest should be:
< meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
< meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
The last line with #integer looks into the google_play_services_version so you don't have to do anything in the future whenever the google play version changes. Do not hard code the version number value or you will have to manually update it often.
MyProject extends BaseGameActivity.
Then to call the leaderboard and update it, their sample code of 2 lines of code runs great. See below.
https://developers.google.com/games/services/android/leaderboards
You have to pass in your leaderboard ID given to you when you link up your app to the google play developer console. It's a String that looks something like: "DkbGvageyBASEWEFCx."
Updating and Getting a leaderboard will crash if you aren't connected. Check out this complete sample code below.
//to update
if (getApiClient().isConnected()) //getAPIClient is part of BaseGameUtils
Games.Leaderboards.submitScore(getApiClient(), leaderboardID, score);
//to show
if (getApiClient().isConnected())
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), leaderboardID), 1337);
Lastly, if you are using an app with a different keystore that has a different SHA1 (Secure Hash Algorithm) than the one that you have on the google play store, then there will be an error and you will not be able to connect. So if you uploaded an app with a keystore with an SHA1 like ab:cd:de... and you're debugging your app, you may see problems since Eclipse will use a default android debug keystore which has a different SHA1.
You will not be able to connect and consequently, you will not be able to use any google play services.
I recommend you look at the sample code called "Trivial Quest."
https://github.com/playgameservices/android-samples
It's under eclipse_compat. This sample code shows one how to sign in and unlock an achievement. If you can sign in, you can do achievements and leaderboards really easily.
There's a lot of stuff but you have given us only a small piece of the puzzle. If you have any more problems, please let us know.

I think, maybe, you need put Google Play Services Library in your dependencies,
In this line :
03-10 17:44:54.071: E/AndroidRuntime(31435): at com.google.android.gms.internal.dw$h.b(Unknown Source)
Probally you have problems with maps dependency of google, the library GMS from google is used
to maps and other services from Google Play Services, if you have problems with that, is possible you have added Wrong versions in your project.
The best way for you is, downalod Google Play Services For Games and put in your project
dependencies.
https://developers.google.com/games/services/downloads/
(this google play services is specific to games )

Related

How i can see stacktrace for crash of my app in play market?

In play market console I see just statistic how many times my app was crashed. How I can see stack for this crashes?
Should I do some additional steps in adding my app to play market. I just added APK.
what I see on playmarket
In the GooglePlay Console, on the left menu in Quality (Качество) section, select Android Vitals -> Crashes and ANRs (Сбои и ошибки ANR in Russian)
It will give you detailed information about crashes.
But to see the full stack trace first you need to upload ReTrace mapping file (Файл сопоставления ReTrace) - you can find this option in "App Bundle Explorer" when selecting your APK version.
Otherwise you'll see an obfuscated stack trace.
Probably you already have this file (mapping.txt) among the generated files of the project. If not, read here how to generate this file: https://support.google.com/googleplay/android-developer/answer/9848633

App crash when connecting to google play games - A fatal developer error has occurred

My game stops when I try to connect it with the google play games. It was working. But suddenly this is happening. It's showing development error occurred. Here's the logcat.
07:34.150 2144-2144/com.sennovations.countermaster E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sennovations.countermaster, PID: 2144
java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
at com.google.android.gms.common.internal.zze.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
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:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I have added the meta tags in the manifest.
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Any help would be appreciated. Thanks
Based on your comments I infer that this wasn't your issue, but as I encountered a similar error that I resolved as follows, I'll add this answer:
Google's documentation (here, for instance) currently instructs us to add
compile 'com.google.android.gms:play-services:11.0.4'
to build.gradle. Notice that it currently advises version 11.0.4. Google adds:
Be sure you update this version number each time Google Play services is updated.
This one line appears to be quite possibly some of the worst advice ever given.
Why? Two reasons.
Suppose you use their free BaseGameUtils, which Google itself encourages. Its build.gradle is set up to use version 8.4.0:
ext.gms_library_version = '8.4.0'
I did this, and used the webpage's advice to use version 11.0.4. The disagreement in library numbers caused the app to crash on both Android Studio emulator and a test device with a stack trace similar to the one above.
To be fair, Android Studio will warn you that things can go wrong with the different version numbers: if you open the Manifest file, it will underline the version numbers and whine that it finds two different version numbers, and it will even tell you which version numbers disagree, but -- this is key -- it won't tell you where to find the other file(s) with different version numbers. If you are importing several libraries, and/or compiling dependencies on GitHub or elsewhere, it can be a bit of a challenge to find the cause.
If your app requests Play Games services 11.0.4, but your emulator and/or phone have a lower version number (e.g., 11.0.2 as on my emulator), then the Games API's connect() will give status RESULT_CANCEL to onActivityResult(). The documentation on these result codes leaves something to be desired, so this can take a while to debug -- in fact, I think I think the crashes above were my only clue that the problem might be with the API version number.
There is a way to check that the device supports the requested API, but most of Google's documentation doesn't tell you to do it, and even BaseGameUtils doesn't seem to check for it. (You want to look at GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE.)
In my particular case, the problem was solved by changing my app's play-services version to 8.4.0. Works beautifully now.

Android Admob implementation: Get the error : "Google Play Services resources were not found"

I tried to upgrade my implementation of AdMob. Using the GoogleAdMobSDK, I would like to turn into the google-play-services-lib.
The ad appears. So it seems ok, but I still got this error at the method call loadAd() in log
Requesting resource 0x7f0c000d failed because it is complex
GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Here's my checklist:
I import the library project in my workspace, copying the source.
I reference the library into my project
I add the meta-data in the Manifest
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
My code
this.request = new AdRequest.Builder().addTestDevice(id).build();
this.adView = new AdView(context);
this.adView.setAdUnitId(MY_AD_UNIT_ID);
this.adView.setAdSize(AdSize.SMART_BANNER);
...
this.adView.loadAd(request);
The target version for my app in 9 (2.3). I test on Nexus 5 with KitKat version.
I also tried to put the google-play-services-lib jar in the properties, but no result.
I want to be sure that this error could be handle before submit my app.
This is a benign error with the current version of Google Play Services.
Don't worry about it. Submit your app. Get some sleep.

java.lang.NoClassDefFoundError on Android with GoogleAccountCredential.newChooseAccountIntent()

I am developing for Android 4+ with Eclipse Juno ADT bundle + Google Plugin for Eclipse.
I need to programmatically log into a google account to use the Google Calendar API. For
this I am making use of account manager. I get the following error:
05-05 13:28:55.605: E/AndroidRuntime(11186): FATAL EXCEPTION: main
05-05 13:28:55.605: E/AndroidRuntime(11186): java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
05-05 13:28:55.605: E/AndroidRuntime(11186): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent(GoogleAccountCredential.java:171)
05-05 13:28:55.605: E/AndroidRuntime(11186): ...
Here is the code that causes it:
GoogleAccountCredential credential;
credential = GoogleAccountCredential.usingOAuth2(this, CalendarScopes.CALENDAR);
chooseAccount();
private void chooseAccount() {
startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
}
I have searched stackoverflow for solutions. The libs directory contains the calendar
library files for eclipse I imported via google plugin for eclipse (which also put
there the authentication etc... libraries):
android-support-v4.jar
google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-api-services-calendar-v3-rev41-1.14.2-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-http-client-jackson-1.14.1-beta.jar
google-http-client-jackson2-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar
gson-2.1.jar
jackson-core-2.1.3.jar
jackson-core-asl-1.9.11.jar
jsr305-1.3.9.jar
These however do not seem to include
com.google.android.gms.common.AccountPicker
If I import this in my code the import line of code is flagged as an error.
So what's up. I've copied this code from the Google Calendar Sample where it
runs just fine:
http://samples.google-api-java-client.googlecode.com/hg/calendar-android-sample/
That code has exactly the same libs except:
calendar lib is rev33 instead of rev41
jackson and jackson-asl libraries are missing
.properties file for each library file present in sample code but not in my code
So this should not be the problem. However,
looking in the imports section of the code, the google calendar sample code has:
import com.google.android.gms.common.GooglePlayServicesUtil;
but if I try to insert this line of code in my code it is tagged as an error
saying the import com.google.android.gms.common.GooglePlayServicesUtil
cannot be resolved.
This post
java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker
says they were able to
import com.google.android.gms.common.AccountPicker;
But I'd like to know what library that came from.
I even tried looking in the original android calendar sample for the
library from which I can include com.google.android.gms.common.*
by inspecting one file at a time but could not find it. How
is it possible?
What am I doing wrong?
Thanks very very much for all your help.
OK, I've found out what I was missing.
Ensure you have downloaded the Android SDK Services -> Extras -> Google Play services
Follow the instructions provided by the following link
to add the google-play-services-lib library to your project:
http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
Best Regards
I've run into a similar problem lately. My app (not in production yet) would suddenly (since the beginning of May) start throwing uncatchable 'NoClassDefFoundError' error when calling
GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE_FILE)
method. It was happening randomly, usually first time in the morning. I could fix it by re-installing my Google account. Not a good solution for production, though. I've spent frustrating couple of hours trying to resolve it until I finally realized I have another app that does not have the same problem in the same code sequence. So I diff-ed both of them and realized that the "good" one had a different sequence of entries in 'Package Explorer->Project->Properties->Java Build Path' The 'good' one had
'google-play-services.jar' BEFORE
'android-support-v4.jar',
where the 'bad' one had it backwards. So I switched the sequence (using UP, DOWN buttons in the dialog) and it seems to solve the problem. Yet another WT... ? moment! Does anybody have an opinion on this?

upload video to youtube from android using google-api-java-client 1.14.1 or ytd-android-0.2

Further to my earlier question which is not answered
using youtube data in android project
my goal is to upload YouTube video, and after get the URL, then do a search by key developer.
I spent three days and not found yet aworking code for Android.
i try this code that Initially appears to be superior :
How to upload a video to YouTube in Android?
that link to this file
https://code.google.com/p/ytd-android/downloads/list
but i recive toast that write :
"Request made to myytdDomain failed. Please make sure you have the correct domain"
i chack cuple time, but myytdDomain is right...
and in locate error
05-02 20:01:37.889: E/Adreno200-ES20(128): <qgl2DrvAPI_glUseProgram:1318>: **** 293: glUseProgram(6)
05-02 20:01:38.279: E/AndroidRuntime(6775): FATAL EXCEPTION: main
05-02 20:01:38.279: E/AndroidRuntime(6775): java.lang.RuntimeException: Unable to start activity ComponentInfo{android/android.accounts.GrantCredentialsPermissionActivity}: java.lang.NullPointerException
05-02 20:01:38.279: E/AndroidRuntime(6775): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
if someone work recently with this code and it's work or not I'm interested to hear about it...
after this i find this article :
http://diablo-urban-o.com/post/9880535810/uploading-videos-to-youtube-from-android
i try to use it but in fifth Paragraph they order to dawnload Google API Client Library for Java, version 1.14.1-beta
https://code.google.com/p/google-api-java-client/downloads/list
" once you uncompress it you’ll find several jar files but for the youtube functionality we’ll need google-api-client-xxx and google-api-client-googleapis and two more dependencies guava-r09 and jackson-core-asl (you can follow here - it’s in spanish), so all you have to do is to add these libraries to the project build path."
the problem is that whan i unzip this file i discover that there is no google-api-client-xxx jar file and google-api-client-googleapis jar
After I gave up seeking back here to ask if anyone has a way, please write down detailed answer
There are a number of detailed samples for using the Youtube API with the Google API Java Client here:
https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fsamples%2Fjava
In addition, the ZIP for the Google API Java Client certainly does have the jars you're looking for. In the root of the zip there are two directories, "libs" and "libs-sources" (the second which also contains source code, which can be useful for debugging). Note that there is no guava jar anymore as the dependency on guava was removed.

Categories

Resources