Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Android studio google play services - Page 2 — Gideros Forum

Android studio google play services

2

Comments

  • antixantix Member
    I now have leaderboards working and I'm happy but I can't get Achievements working. When I call googleplay:reportAchievement(id, steps) my application crashes.

    To find out what is happening I need to debug right? Well this leads to my other problem.. debugging doesn't work from Anbdroid Studio.

    When I debug to my device the app from inside Android Studio, my google play services login fails, telling me the application is not configured correctly. If I build an APK and install that on my device and then run it, google play logs in just fine.

    So because I can't debug the thing from Android Studio, how can I tell what is happening?

    Right now I feel I should just remove the Achievement button from my game and give up.
  • hgy29hgy29 Maintainer
    @antix, could you make a sample project with the issue, or give me a few pointers on how to get started to reproduce it ? I never used google play services but I'd like to help
  • antixantix Member
    @hgy29 thanks. I don't know if I can pass my project along. I'm using my key to generate a signed APK and if you don't have the same key at your end when you create an APK your app won't be able to even access the Achievements or Leaderboards will it?
  • hgy29hgy29 Maintainer
    I began playing with google play services plugin for android studio, and an automatic plugin integration script is almost ready. It will be in next release, no doubt. You'll have to supply your app id, thats all, gideros will take care of exporting the plugin for you.
    +1 -1 (+4 / -0 )Share on Facebook
  • antixantix Member
    Wow, that's fantastic news, I really look forward to that. I still haven't even installed the latest release :)
  • Awesome, that's so cool!
  • antixantix Member
    So when is the next release due? I find it highly doubtful I will be able to resolve my issues by myself.
  • SinisterSoftSinisterSoft Maintainer
    I think I'm correct in saying that the next release will be sometime this month.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • antixantix Member
    Oh man, I was messing about with IAB which I also could not get working. I deleted that from my project and now the whole thing fails to flipping compile again.
  • antixantix Member
    @billydb have you got the gaming plugin working with achievements? I can call showAchievements() and it shows them. If call reportAchievement() then the app crashes.
  • @antix, no I have seen it load achievements but haven't tried reporting them. I wasn't going to bother with achievements anyway. At least not yet.
  • antixantix Member
    @billydb okay, it would be good if somebody else could test these to see if it is just me having the problem.

    Last night I figured out something cool in Android Studio so I've posted a tutorial on my devblog that shows you how to use your keystore when debugging to a device in Android Studio. This lets you sign into Google Play Services from the device without the "Your app is not configured" message.

    With this working I can now see what is causing the crash when I call reportAchievement()
                                                                    --------- beginning of crash
    07-14 22:32:00.765 23058-23228/com.antix.falling_animals A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 23228 (GLThread 1329)
    To me it looks like some kind of graphic issue? Can anyone shed some light on this?
  • antixantix Member
    edited July 2016
    I have created an entire separate application to test what is happening with Google Play Services. As my other project the results are the same, showLeaderboard() and showAchievements() work fine, but reportAchievement() crashes the app.. Here is a logcat thing..
    07-15 15:08:53.969 17936-18010/com.antix.play_services A/art: art/runtime/check_jni.cc:65] 
    JNI DETECTED ERROR IN APPLICATION: JNI CallStaticVoidMethodV called with pending exception 'java.lang.NoSuchMethodError' thrown in void com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame():-2
    07-15 15:08:53.969 17936-18010/com.antix.play_services A/art: art/runtime/check_jni.cc:65]     in call to CallStaticVoidMethodV
    07-15 15:08:53.969 17936-18010/com.antix.play_services A/art: art/runtime/check_jni.cc:65]     from void com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame()
    -- lots more error lines were in here <img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/smile.png" title=":)" alt=":)" height="20" />
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   | held mutexes=
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #00 pc 00012960  /system/lib/libc.so (syscall+28)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #01 pc 000aa063  /system/lib/libart.so (art::ConditionVariable::Wait(art::Thread*)+98)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #02 pc 001f8f21  /system/lib/libart.so (art::Monitor::Wait(art::Thread*, long long, int, bool, art::ThreadState)+1036)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #03 pc 001fa41d  /system/lib/libart.so (art::Monitor::Wait(art::Thread*, art::mirror::Object*, long long, int, bool, art::ThreadState)+136)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #04 pc 00207609  /system/lib/libart.so (art::Object_waitJI(_JNIEnv*, _jobject*, long long, int)+44)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   native: #05 pc 0000060b  /data/dalvik-cache/arm/system@framework@boot.oat (Java_java_lang_Object_wait__JI+102)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   at java.lang.Object.wait!(Native method)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   - waiting on <0x00791f16> (a java.lang.Object)
    07-15 15:08:54.541 17936-18010/com.antix.play_services A/art: art/runtime/runtime.cc:289]   at java.lang.Thread.parkFor(Thread.java:1220)
     
                                                                  --------- beginning of crash
    07-15 15:08:54.542 17936-18010/com.antix.play_services A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 18010 (GLThread 915)
    I'm using the gaming plugin which I have working with the latest Google Play Services (9.2.x) in Android Studio. I have a modified (after modifying some of the supplied java files from the allplugins folder). Regardless, this crash is the same as I was getting with the default setup using Play Services 7.8.x

    So, is this a bug that has crept into Gideros somewhere along the line?
  • hgy29hgy29 Maintainer
    Thanks @antix, this logcat is very useful!

    Looks like there is a definition mismatch between C and Java sides of the reportAchievement() processing. Can you try the following changes in your gaming plugin's Java files and report back ?

    In src/com/giderosmobile/android/plugins/gaming/Game.java, around line 240, change:
    public static void reportAchievement(String type, String id, int numSteps, int immediate)
    to
    public static void reportAchievement(String type, String id, double numSteps, int immediate)
  • antixantix Member
    edited July 2016
    @hgy29, changing that line causes a build error..
    Error:(243, 41) error: incompatible types: possible lossy conversion from double to int
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
    :app:compileDebugJavaWithJavac FAILED
    Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    Which is complaining about the numSteps in the code..
    public static void reportAchievement(String type, String id, double numSteps, int immediate)
    {
    String adp = modifyName(type);
    if(games.containsKey(adp))
    	games.get(adp).reportAchievement(id, numSteps, immediate);
    }
  • hgy29hgy29 Maintainer
    Ah, it ought to be a warning, can you just cast numSteps to an int for the call to reportAchievement a few lines below:
    games.get(adp).reportAchievement(id, (int)numSteps, immediate);
  • hgy29hgy29 Maintainer
    The thing is lua/C code treat numSteps as a double, while Java side carry it as an integer everywhere.
  • antixantix Member
    Cool, that works!! However its not tormenting the achievements :(

    I will check my other code, but at least it;s not crashing now :)
  • hgy29hgy29 Maintainer
    Great, I'll push that fix into github then.
  • antixantix Member
    I meant to say not "incrementing" the achievements :)
  • hgy29hgy29 Maintainer
    What do you mean by incrementing ? From what I saw in the code google play's achievements have only two states: locked and unlocked, and calling reportAchievement just unlock the achievement
  • hgy29hgy29 Maintainer
    However google's api do have a setSteps() API, don't know if it is something new or not but probably gideros should call this if numSteps>0 instead of unlock

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    edited July 2016
    Can you change the body of reportAchievement functions at line 147 of xxx/gaming/frameworks/GameGoogleplay.java to:
    	public void reportAchievement(final String id, int numSteps, int immediate) {
    		if(isAvailable())
    		{
    			if(mHelper != null && mHelper.isSignedIn())
    			{
    				if(immediate == 1)
    				{
    					PendingResult<UpdateAchievementResult> result;
    					if (numSteps>0)
    						result = Games.Achievements.setStepsImmediate(mHelper.getApiClient(), id, numSteps);
    					else
    						result = Games.Achievements.unlockImmediate(mHelper.getApiClient(), id);
    					ResultCallback<UpdateAchievementResult> mResultCallback = new
    							ResultCallback<UpdateAchievementResult>() {
    						<a href="http://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
    						public void onResult(UpdateAchievementResult result) {
    							if(result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK || result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCKED){
    								Game.reportAchievementComplete(me, id);
    							}
    							else
    							{
    								Game.reportAchievementError(me, id, "Error: "+result.getStatus().getStatusCode());
    							}
    						}
    					};
    					result.setResultCallback(mResultCallback);
    				}
    				else
    				{
    					if (numSteps>0)
    						Games.Achievements.setSteps(mHelper.getApiClient(), id, numSteps);
    					else
    						Games.Achievements.unlock(mHelper.getApiClient(), id);
    				}
    			}
    			else
    	    		Game.reportAchievementError(this, id, Game.NOT_LOG_IN);
    		}
    		else
    		{
    			Game.reportAchievementError(this, id, Game.LIBRARY_NOT_FOUND);
    		}
    	}
    and see if it works ? You'll have to supply the target steps count, or 0 for just unlocking.
  • antixantix Member
    Right. I can report that now the game does not crash when reporting achievements. Unfortunately my game receives no "REPORT_ACHIEVEMENT_COMPLETE" event and when I call showAchievements() there is no progress recorded.
  • hgy29hgy29 Maintainer
    Do you use immediate mode (add true as last argument to your reportAchievement call) ? Do you get some REPORT_ACHIEVEMENT_ERROR instead ?
  • antixantix Member
    edited July 2016
    yes I am using true as the last argument but I don't have that event handler. I'll add it right now.

    Added the event handler and I am not receiving either event (success or fail)

    This is my googleplay code..
      require "gaming"
      googleplay = Gaming.new("googleplay")
     
    googleplay:addEventListener(Event.LOGIN_COMPLETE, function()
      LOG("LOGIN_COMPLETE")
     
      local game = GAME
      game.loggedIn = true
      local nextAction = game.nextAction
      if nextAction == "leaderboard" then
        googleplay:showLeaderboard("CgkIpqblirkGEAIQBg")
      elseif nextAction == "achievements" then
        googleplay:showAchievements()
      end
      game.nextAction = "none"
    end)
     
    googleplay:addEventListener(Event.LOAD_SCORES_COMPLETE, function(e)
      LOG("LOAD_SCORES_COMPLETE")
      printR(e)
    end)
     
    googleplay:addEventListener(Event.REPORT_SCORE_COMPLETE, function()
      LOG("REPORT_SCORE_COMPLETE")
    end)
     
    googleplay:addEventListener(Event.REPORT_SCORE_ERROR, function(e)
      LOG("REPORT_SCORE_ERROR")
      LOG(e.error)
    end)
     
    googleplay:addEventListener(Event.LOAD_ACHIEVEMENTS_COMPLETE, function(e)
      LOG("LOAD_ACHIEVEMENTS_COMPLETE")
      printR(e.achievements)
    end)
     
    googleplay:addEventListener(Event.REPORT_ACHIEVEMENT_COMPLETE, function(e)
      LOG("REPORT_ACHIEVEMENT_COMPLETE")
      LOG(e.id)
    end)
     
    googleplay:addEventListener(Event.REPORT_ACHIEVEMENT_ERROR, function(e)
      LOG("REPORT_ACHIEVEMENT_ERROR")
      LOG(e.id)
      LOG(e.error)
    end)
     
    googleplay:addEventListener(Event.STATE_LOADED, function(e)
      LOG("STATE_LOADED")
      print(e.key, e.isFresh, e.data)
    end)
     
    googleplay:addEventListener(Event.STATE_ERROR, function(e)
      LOG("STATE_ERROR")
      print(e.key, e.error)
    end)
     
    googleplay:addEventListener(Event.STATE_CONFLICT, function(e)
      LOG("STATE_CONFLICT")
      print(e.key, e.version, e.localData, e.serverData)
      googleplay:resolveState(e.key, e.version, "data resolved in conflict")
    end)
     
    googleplay:addEventListener(Event.STATE_DELETED, function(e)
      LOG("STATE_DELETED")
      print(e.key)
    end)
  • antixantix Member
    edited July 2016
    @hgy29, sorry I missed your post about changing the reportAchievement() function, just doing that now..

    Changing the code and running crashes the game on launching
    --------- beginning of crash
    07-15 21:05:48.252 19115-19115/com.antix.falling_animals E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.antix.falling_animals, PID: 19115
    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "lua_canyield" referenced by "libgideros.so"...
    at java.lang.Runtime.loadLibrary(Runtime.java:371)
    at java.lang.System.loadLibrary(System.java:988)
    at com.giderosmobile.android.FallingAnimalsActivity.<clinit>(FallingAnimalsActivity.java:28)
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.Class.newInstance(Class.java:1606)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.access$800(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    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:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  • hgy29hgy29 Maintainer
    @antix, this is something else this time, looks like your new project as been exported with 2016.6 in assets only mode. Either switch back to 2016.4 for now or do a clean export with 2016.6 and re-do eventual changes for plugin insertion
  • antixantix Member
    Hmm, even after undoing the changes and rebuilding, it crashes on launch now. Maybe this has something to do with updating my Gideros to test the luac.exe thing.
  • antixantix Member
    edited July 2016
    @antix, this is something else this time, looks like your new project as been exported with 2016.6 in assets only mode. Either switch back to 2016.4 for now or do a clean export with 2016.6 and re-do eventual changes for plugin insertion
    Snap! So I figure I can just export something with the new version and copy the libs and stuff to my existing project in Android Studio?

    Okay that failed. I'm going to get this working in the morning. Thanks so much for all of your help today @hgy29!!
Sign In or Register to comment.