question

phosphor-dev avatar image
phosphor-dev asked

Clicking on GameCircle notification popup raises IllegalAccessError

hi, in our integration, after GameCircle is initialized and the little popup notification toast appears, clicking on that always results in the following exception: 12-04 00:34:35.821 8349 8349 E AndroidRuntime: FATAL EXCEPTION: main 12-04 00:34:35.821 8349 8349 E AndroidRuntime: java.lang.IllegalAccessError: ServiceFactory must be initialized before using 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at com.amazon.ags.html5.factory.ServiceFactory.getInstance(ServiceFactory.java:173) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at com.amazon.ags.html5.overlay.GameCircleUserInterface.onCreate(GameCircleUserInterface.java:37) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5158) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2183) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2283) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:146) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1245) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.os.Looper.loop(Looper.java:151) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5152) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 12-04 00:34:35.821 8349 8349 E AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) any ideas? thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Phosphor-dev, I have sent you a sample app integrated with Game Circle to your registered mail id. Please check. Thank you for writing to us.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

phosphor-dev avatar image
phosphor-dev answered
hi there, thanks for the reply. i notice in the sample code that AmazonGamesClient.initialize() is called in onCreate(). and there is no onPause()/onResume() code to call release()/initialize(), as is recommended here: https://developer.amazon.com/sdk/gamecircle/documentation/gamecircle-init.html#Section5 is that intentional?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi phosphor-dev, Thank you for writing back. Yes. onResume() is the best place for AmazonGamesClient.initialize() as documented. Thanks for pointing this out. Did the sample works with out issue? Did you observe there the issue you reported before?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

phosphor-dev avatar image
phosphor-dev answered
the sample works yes. when the toast appears i can touch it and i am taken to the profile webview. my app still has the same result however. touching the toast still leads to the same crash. in the logcat output, i see the following: 12-10 22:24:35.592 29527 29617 D GameCircleClient: initialize_internal() executing on thread:pool-3-thread-1 ... 12-10 22:24:38.014 29527 29527 D KindleFireIPCProxy: authResult: AUTHORIZED ... 12-10 22:24:38.022 29527 29527 D KindleFireIPCProxy: Changing Status from:INITIALIZING to: SERVICE_CONNECTED so it would appear that the API key is valid, however my onServiceNotReady() callback is always invoked from here with CANNOT_INITIALIZE: 12-11 00:02:20.311 30269 30429 W System.err: at JavaApp$1.onServiceNotReady(JavaApp.java:371) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.api.AmazonGamesClient$2.onComplete(AmazonGamesClient.java:236) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.api.AmazonGamesClient$2.onComplete(AmazonGamesClient.java:229) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.client.AGResponseHandleImpl.callCallback(AGResponseHandleImpl.java:72) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.client.AGResponseHandleImpl.setResponse(AGResponseHandleImpl.java:57) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.client.ClientBase$AsyncTaskWrapper.setResponse(ClientBase.java:151) 12-11 00:02:20.311 30269 30429 W System.err: at com.amazon.ags.html5.service.AsynchronousReplyMessenger$1.run(AsynchronousReplyMessenger.java:79) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:234) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 12-11 00:02:20.311 30269 30429 W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 12-11 00:02:20.311 30269 30429 W System.err: at java.lang.Thread.run(Thread.java:856) which seems to indicate that SessionClient.initializeSession() is failing (i.e. AGS seems to be getting partially initialized at least with a valid API key). my onServiceNotReady() callback calls AmazonGamesClient.shutdown() to clean up (based off another sample i had from another forum), which may be the reason that touching the GameCircle toast leads to a crash, is it not recommended to call shutdown() there? i can remove that, but it would still seem odd that onServiceNotReady() is invoked regardless (i.e. seems odd that the toast appears at all if onServiceNotReady() will be invoked). i also see several of these (with different GUIDs) in my app's logcat (not sure if this might be related), which i don't see in the logcat for the sample app. looks like the timeout tasks are firing before their matching async requests are being completed: 12-10 23:35:46.160 28243 29186 W GC_AsynchronousReplyMessenger: Request df25c755-9b4d-4bde-868d-e469ea68387c timed out. any further thoughts?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
AmazonGamesClient.shutdown() - Fully releases all resources and operations associated with an initialized AmazonGamesClient. Donot Call it onServiceReady. AmazonGamesClient object would be used in accessing different features of Amazon Game Circle Api. AmazonGamesClient is the single entry point to access the Amazon Games Client. Upon initialization, the AmazonGamesClient will begin an attempt to authorize on a background thread. Be sure to wait for the AmazonGamesCallback before using the client. Apps-SDK/Android/GameCircle/documentation/API-Reference/index.html
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

phosphor-dev avatar image
phosphor-dev answered
>> Donot Call it onServiceReady ...it's called from onServiceNotReady(), what i'm curious about is if it's expected to get one or more onServiceNotReady() calls before the actual onServiceReady() ? because in that case calling shutdown() wouldn't make sense. otherwise if receiving onServiceNotReady() means that the client will never become available for use and that initialize() has failed, then it seems like shutdown() would be appropriate to call there to clean up the failed initialize(), no? >> Be sure to wait for the AmazonGamesCallback before using the client ...i do, i cache off the agsClient in onServiceReady() (per the sample code), so i don't use that if it's still 'null'. fwiw as noted in the original post, the sequence of events that i've run into is as follows: 1) i call initialize() with only WhisperSync as a feature 2) from the logcat i can see that the API key is validated 3) i receive onServiceNotReady() with CANNOT_INITIALIZE 4) the toast appears "Welcome, " (touching on that results in a crash due to ServiceFactory == null) 5) i never receive onServiceReady() private AmazonGamesClient agsClient = null; private AmazonGamesCallback agsCallback = new AmazonGamesCallback() { @Override public void onServiceNotReady(AmazonGamesStatus status) { //unable to use service Logger.LogOut("AMAZON_CLOUD", "AGS callback - onServiceNotReady(): " + status.toString()); AmazonGamesClient.shutdown(); } @Override public void onServiceReady(AmazonGamesClient amazonGamesClient) { // ready to use service Logger.LogOut("AMAZON_CLOUD", "AGS callback - onServiceReady()"); agsClient = amazonGamesClient; } }; @Override protected void onResume() { // ... //Whispersync only EnumSet agsFeatures = EnumSet.of( AmazonGamesFeature.Whispersync ); AmazonGamesClient.initialize(this, agsCallback, agsFeatures); } @Override protected void onPause() { // ... if(agsClient != null) { agsClient.release(); agsClient = null; } }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rihards Gailis avatar image
Rihards Gailis answered
I have exactly same behavior, onServiceNotReady is fired, then client is initialized and onServiceReady is not called, thus my app actually never knows that client is now ready Did you find any fix for that?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Rihards, I have forwarded this issue to internal appropriate team. I will let you know what they say about this issue. Meanwhile, can you please let us know about the below details? 1. Tested device name 2. Used SDK version 3. Is it happening on Android SDK?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon Customer avatar image
Amazon Customer answered
> Hi Rihards, > > I have forwarded this issue to internal appropriate > team. I will let you know what they say about this > issue. Meanwhile, can you please let us know about > the below details? > 1. Tested device name > 2. Used SDK version > 3. Is it happening on Android SDK? Has there been any movement on this? I find myself with the same exact problem in August 2015. I can't find anything on the Web to help.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jamie Grossman avatar image
Jamie Grossman answered
Hi there, I tried to reproduce this issue myself, but I am able to select the pop ups with no issue. Could you provide some more information on your set up? Including which device it was reproduced on (amazon or not), which version of the Android SDK, etc. Thanks! Jamie
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.