question

ssnannapaneni avatar image
ssnannapaneni asked

sample code

hi, i have done all the process but when my app runs the game circle window is not coming. is there any sample app for game circle ? Message was edited by: ssnannapaneni
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 Ssnannapaneni, Thank you for your post. I have you sent sample code in your registered mail id. Do you see any error report in logcat while trying to launch Game Circle window? Please post the code you are trying to run and that's not working.
10 |5000

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

ssnannapaneni avatar image
ssnannapaneni answered
Hi, Thanks for giving code,i have generated signature,achievement,leaderboard in sample application, but i didn't get game circle window and i got these errors as bellow 05-24 17:53:33.086: D/AGC_ServiceProxy(4717): binding result:true 05-24 17:53:33.109: E/GC_AmazonGamesClient(4717): Failed to enable softkey button: java.lang.ClassNotFoundException: com.amazon.ags.app.util.SoftkeyBarWrapper 05-24 17:53:33.109: I/dalvikvm(4717): Total arena pages for JIT: 11 05-24 17:53:33.109: D/AGC_ServiceProxy(4717): synchronousBinder:null serviceMessengerClient:android.os.Messenger@40529290 05-24 17:53:33.109: D/AGC_ServiceProxy(4717): synchronousBinder:null serviceMessengerClient:android.os.Messenger@40529290 05-24 17:53:33.109: D/AGC_ServiceProxy(4717): Client is bound to service 05-24 17:53:33.109: D/AGC_ServiceProxy(4717): Session Id:4ea13cc6-2636-4767-b845-027cc39f5f4c 05-24 17:53:34.195: D/AGC_ServiceProxy(4717): Handling authorize callback 05-24 17:53:34.195: D/AGC_ServiceProxy(4717): authResult: CANNOT_AUTHORIZE 05-24 17:53:34.195: D/AGC_ServiceProxy(4717): Changing Status from:INITIALIZING to: CANNOT_AUTHORIZE 05-24 17:53:34.195: I/AGC_AmazonGamesStatusHandler(4717): Game received status update of: CANNOT_AUTHORIZE
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 Ssnannapaneni, When testing your AGS integration, if you get the CANNOT_AUTHORIZE AmazonGamesStatus from the Initialize() callback, it is most likely that you have not registered the package name and signature of the game build properly. Please refer this link to authenticate all the GC requests from your app, https://developer.amazon.com/sdk/gamecircle/documentation/gamecircle-setup.html#Section3 Please note, you need to extract the correct signature out of your build to register it against your package in GC settings of you app defined in distribution portal. So you need to set the correct .keystore file (the one you are using to sign your apk) path in the keytool command. Hope it makes sense.
10 |5000

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

Narasimha avatar image
Narasimha answered
Hi Sujoy, i generated signature and entered in one of my apps with package name as per guide line. And also created game circle nick Name.I created a sample application by using the sample code which was sent by you. my application code is as bellow..when i execute this i got the same error i.e cannot_athorize.Can you please tell me the solution. and this is my app code import java.util.EnumSet; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.amazon.ags.api.AGResponseCallback; import com.amazon.ags.api.AGResponseHandle; import com.amazon.ags.api.AmazonGames; import com.amazon.ags.api.AmazonGamesCallback; import com.amazon.ags.api.AmazonGamesClient; import com.amazon.ags.api.AmazonGamesFeature; import com.amazon.ags.api.AmazonGamesStatus; import com.amazon.ags.api.achievements.AchievementsClient; import com.amazon.ags.api.achievements.GetAchievementResponse; import com.amazon.ags.api.achievements.GetAchievementsResponse; import com.amazon.ags.api.achievements.UpdateProgressResponse; import com.amazon.ags.api.leaderboards.LeaderboardsClient; import com.amazon.ags.api.leaderboards.SubmitScoreResponse; public class BadGameActivity extends Activity { // We'll initialize this once the application has launched. AmazonGames agsGameClient; // Make a list of the Amazon GameCircle features your game uses. // Only show the features you are using. EnumSet agsGameFeatures = EnumSet.of( AmazonGamesFeature.Achievements, AmazonGamesFeature.Whispersync, AmazonGamesFeature.Leaderboards ); // Create a callback to handle initialization result codes. AmazonGamesCallback agsGameCallback = new AmazonGamesCallback() { @Override public void onServiceReady() { } @Override public void onServiceNotReady(AmazonGamesStatus reason) { switch (reason) { case CANNOT_AUTHORIZE: /** * The service could not authorize the client. This should only * occur if the network is not available the first time the game * attempts to connect. */ Log.i(TAG, "---- CANNOT_AUTHORIZE"); Toast.makeText(BadGameActivity.this, "CANNOT_AUTHORIZE", Toast.LENGTH_SHORT).show(); break; case CANNOT_BIND: /** *The service could not bind either because it does not exist, * or permissions have not been granted. This will also occur * when your game is executed on a non-fire device that does not * have Amazon GameCircle installed. */ Log.i(TAG, "---- CANNOT_BIND"); Toast.makeText(BadGameActivity.this, "CANNOT_BIND", Toast.LENGTH_SHORT).show(); break; case NOT_AUTHENTICATED: /** * The device is not registered with an account. */ Log.i(TAG, "---- NOT_AUTHENTICATED"); Toast.makeText(BadGameActivity.this, "NOT_AUTHENTICATED", Toast.LENGTH_SHORT).show(); break; case NOT_AUTHORIZED: /** * The game in not authorized to use the service. Check your * package name and signature registered in the Developer's * Portal. */ Log.i(TAG, "---- NOT_AUTHORIZED"); Toast.makeText(BadGameActivity.this, "NOT_AUTHORIZED", Toast.LENGTH_SHORT).show(); break; case SERVICE_NOT_OPTED_IN: /** * The device is not opted-in to use the service. */ Log.i(TAG, "---- SERVICE_NOT_OPTED_IN"); Toast.makeText(BadGameActivity.this, "SERVICE_NOT_OPTED_IN", Toast.LENGTH_SHORT).show(); break; default: break; } } }; protected String TAG = "BadGameActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bad_game); // Initialize Amazon GameCircle. agsGameClient = AmazonGamesClient.initialize( getApplication(), agsGameCallback, agsGameFeatures); Button submitAchievementBtn = (Button) findViewById(R.id.button2); submitAchievementBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText editText = (EditText) findViewById(R.id.editText1); float score = 10.0f; try { score = new Integer(editText.getText().toString()); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } AchievementsClient acClient = agsGameClient.getAchievementsClient(); AGResponseHandle handle = acClient.updateProgress("achievement", score); // Optional callback to receive notification of success/failure. handle.setCallback(new AGResponseCallback () { @Override public void onComplete(UpdateProgressResponse result) { if (result.isError()) { Log.i(TAG, "Error , while submitting the clicks"); Toast.makeText(BadGameActivity.this, "Error , while submitting the clicks", Toast.LENGTH_SHORT).show(); } else { // Continue game flow. Log.i(TAG, "Successfully submitted the clicks!. Continue the game"); Toast.makeText(BadGameActivity.this, "Successfully submitted the clicks!. Continue the game", Toast.LENGTH_SHORT).show(); } } }); } }); Button btnAchievementsOverlay = (Button) findViewById(R.id.button3); btnAchievementsOverlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AchievementsClient acClient = agsGameClient.getAchievementsClient(); acClient.showAchievementsOverlay(); AGResponseHandle ach = acClient.getAchievement("achievement"); ach.setCallback(new AGResponseCallback () { @Override public void onComplete(GetAchievementResponse getAchievementResponse) { Log.i(TAG, "getAchievementResponse.getAchievement() -" + getAchievementResponse.getAchievement()); } }); AGResponseHandle achs = acClient.getAchievements(); achs.setCallback(new AGResponseCallback () { @Override public void onComplete(GetAchievementsResponse getAchievementsResponse) { Log.i(TAG, "getAchievementResponse.getAchievement() -" + getAchievementsResponse.getAchievementsList()); } }); } }); Button submitLeaderBtn = (Button) findViewById(R.id.button1); submitLeaderBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText editText = (EditText) findViewById(R.id.editText2); long longScoreValue = 10; try { longScoreValue = new Integer(editText.getText().toString()); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } LeaderboardsClient lbClient = agsGameClient.getLeaderboardsClient(); final Object userData[] = null; AGResponseHandle handle = lbClient.submitScore("leaderboard", longScoreValue, userData); // Optional callback to receive notification of success/failure. handle.setCallback(new AGResponseCallback () { @Override public void onComplete(SubmitScoreResponse result) { if (result.isError()) { Log.i(TAG, "Error , while submitting the clicks"); Toast.makeText(BadGameActivity.this, "Error , while submitting the clicks", Toast.LENGTH_SHORT).show(); } else { Log.i(TAG, "Successfully submitted the clicks!. Continue the game"); Toast.makeText(BadGameActivity.this, "Successfully submitted the clicks!. Continue the game-"+userData, Toast.LENGTH_SHORT).show(); } } }); } }); Button btnOpenLeaderboardsOverlay = (Button) findViewById(R.id.button4); btnOpenLeaderboardsOverlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { LeaderboardsClient lbClient = agsGameClient.getLeaderboardsClient(); lbClient.showLeaderboardsOverlay(); } }); } @Override protected void onStop() { finish(); super.onStop(); } }
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 Narasimha, Thank you for your post. Basically, CANNOT_AUTHORIZE comes for improper signature whitelisting in the GC setting of the app in dev portal. This is the command you should use to extract the signature from your build if you are using the android default debug keystore to sign you build, keytool -exportcert -alias androiddebugkey -keystore "" -storepass android | openssl sha1 -binary | openssl base64 In linux, path_to_keystore is " ~/.android/debug.keystore". In windows you it should be in the user/.android directory. If you are using your own .keystore then the keystore path, alias and storepass should be given properly according to .keystore. I think you have done this step already. Could you please re run the command properly and confirm that the signature you are getting are the same with the one registered in your GC setting in the portal?
10 |5000

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

Narasimha avatar image
Narasimha answered
Hi sujoy, Thanks for your guidence..I got the game circle window.
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 Narasimha, Thank you for your post. How the problem is solved? Have you tried to re run the command?
10 |5000

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

Narasimha avatar image
Narasimha answered
Hi Sujoy, Yes,I tried to re run the command in two steps as per shown in the Forums. After that I got correct signature and placed it in GC settings then after my app executed successfully. 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.

pitup3 avatar image
pitup3 answered
hi Narasimha thank you, your sample code realy help'd me alot , i have same issue just lik you Message was edited by: pitup3
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 Pitup3, Please go through my previous message in this thread ( https://forums.developer.amazon.com/forums/thread.jspa?messageID=3935#3935), Narasimha was able to solve his problem that way. 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.