Can't update Amazon apps that had GameCircle

I have an Amazon app that used the GameCircle plugin, which I am updating for the first time since March 2019. I know that GameCircle was disconnected back in 2018, but existing apps are still supposed to support it. However, when I tried to build my app today with Solar2D Build 2022.3673, I ran into the Error 256, which only occurs if the GameCircle plugin is included in the build.settings. The specific error is:

Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

My build.settings has:

    ["plugin.gamecircle"] =
    {
      publisherId = "COM_INNOVATIVELEISURE",
      supportedPlatforms = { ["android-kindle"] = true }
    },

Full output in the console when building:

/private/var/folders/80/73y5tf3x0019_mb2qykw72980000gn/T/CLtmp7UX2Du/template/app/src/main/AndroidManifest.xml Error:
	Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':App:processReleaseMainManifest'.
> Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 18s
Android build failed (256) after 22 seconds
ERROR: Build Failed: Error code: 256

Is it possible to get it to build with this plugin?

This is the GameCircle stuff inside my AndroidManifest.xml:

       <activity android:name="com.amazon.ags.html5.overlay.GameCircleUserInterface" 
					android:theme="@style/GCOverlay" android:hardwareAccelerated="false"></activity>
				<activity
				  android:name="com.amazon.identity.auth.device.authorization.AuthorizationActivity"
				  android:theme="@android:style/Theme.NoDisplay"
				  android:allowTaskReparenting="true"
				  android:launchMode="singleTask">
				  <intent-filter>
				     <action android:name="android.intent.action.VIEW" />
				     <category android:name="android.intent.category.DEFAULT" />
				     <category android:name="android.intent.category.BROWSABLE" />
				     <data android:host="com.dsi.fashion2" android:scheme="amzn" />
				  </intent-filter>
				</activity>
				<activity android:name="com.amazon.ags.html5.overlay.GameCircleAlertUserInterface" 
				android:theme="@style/GCAlert" android:hardwareAccelerated="false"></activity>
				<receiver
				  android:name="com.amazon.identity.auth.device.authorization.PackageIntentReceiver"
				  android:enabled="true">
				  <intent-filter>
				     <action android:name="android.intent.action.PACKAGE_INSTALL" />
				     <action android:name="android.intent.action.PACKAGE_ADDED" />
				     <data android:scheme="package" />
				  </intent-filter>
				</receiver>

So basically it seems like it wants me to add ‘android:exported=“true”’’ to the tags for com.amazon.identity.auth.device.authorization.AuthorizationActivity and com.amazon.identity.auth.device.authorization.PackageIntentReceiver.

So I tried to define it in my build.settings under applicationChildElements but the compiler then complained I had a duplicate element defined.

e.g.

android = 
{
   applicationChildElements =
   {
      [[
        <activity android:name="com.amazon.identity.auth.device.authorization.AuthorizationActivity" android:exported="true">
        </activity>
      ]],
      [[
        <receiver android:name="com.amazon.identity.auth.device.authorization.PackageIntentReceiver" android:exported="true">
        </receiver>
      ]],   
   },

Build output:

/private/var/folders/80/73y5tf3x0019_mb2qykw72980000gn/T/CLtmptoaivO/template/app/src/main/AndroidManifest.xml:87:11-88:20 Error:
	Element activity#com.amazon.identity.auth.device.authorization.AuthorizationActivity at AndroidManifest.xml:87:11-88:20 duplicated with element declared at AndroidManifest.xml:60:5-71:16
/private/var/folders/80/73y5tf3x0019_mb2qykw72980000gn/T/CLtmptoaivO/template/app/src/main/AndroidManifest.xml:90:11-91:20 Error:
	Element receiver#com.amazon.identity.auth.device.authorization.PackageIntentReceiver at AndroidManifest.xml:90:11-91:20 duplicated with element declared at AndroidManifest.xml:74:5-82:16
/private/var/folders/80/73y5tf3x0019_mb2qykw72980000gn/T/CLtmptoaivO/template/app/src/main/AndroidManifest.xml Error:
	Validation failed, exiting

OK, so I guess I need to know how to modify an existing element in the manifest.xml without having to declare it again. Anyone?

This should be fixed now. Try building again.

Thank you @vlads, that was quick!

However, I see this error now in my build output:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':App:checkReleaseDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class org.apache.http.client.methods.HttpPatch found in modules jetified-httpclient-4.5 (org.apache.httpcomponents:httpclient:4.5.5) and jetified-plugins (plugins.jar)
     
     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 36s
Android build failed (256) after 40 seconds
ERROR: Build Failed: Error code: 256

Please help me out by tracking down which plugin causes it. I can build with just game circle without this issue

Good idea… So I commented out the first possible culprit – plugin.gpgs.v2 – and it built fine now.

    ["plugin.gpgs.v2"] =        
    {          
      publisherId="com.coronalabs",
      supportedPlatforms={android=true}        
    },

Is there a way to block this automatically under ‘supportedPlatforms’ when building for Amazon? Adding [“android-kindle”] = false didn’t work.

A new issue is that when I attempt to show the leaderboard there is a RunTime error. I’m calling gameNetwork.Leaderboard.OpenOverlay() (this used to work fine) :

Mi A1: ERROR: Runtime error
Mi A1: java.lang.NullPointerException: Attempt to invoke interface method 'com.amazon.ags.api.AGResponseHandle com.amazon.ags.api.leaderboards.LeaderboardsClient.showLeaderboardsOverlay(java.lang.Object[])' on a null object reference
Mi A1: Java Stack Trace:
Mi A1: 	plugin.gamecircle.LuaLoader.OpenLeaderboardOverlay(LuaLoader.java:1027)
Mi A1: 	plugin.gamecircle.LuaLoader$OpenLeaderboardWrapper.invoke(LuaLoader.java:2236)
Mi A1: 	com.ansca.corona.JavaToNativeShim.nativeRender(Native Method)
Mi A1: 	com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:205)
Mi A1: 	com.ansca.corona.Controller.updateRuntimeState(Controller.java:364)
Mi A1: 	com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:434)
Mi A1: 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625)
Mi A1: 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)
Mi A1: stack traceback:
Mi A1: 	[C]: in function 'OpenOverlay'
Mi A1: 	?: in function <?:87>
Mi A1: ERROR: Runtime error
Mi A1: java.lang.NullPointerException: Attempt to invoke interface method 'com.amazon.ags.api.AGResponseHandle com.amazon.ags.api.leaderboards.LeaderboardsClient.showLeaderboardsOverlay(java.lang.Object[])' on a null object reference
Mi A1: Java Stack Trace:
Mi A1: 	plugin.gamecircle.LuaLoader.OpenLeaderboardOverlay(LuaLoader.java:1027)
Mi A1: 	plugin.gamecircle.LuaLoader$OpenLeaderboardWrapper.invoke(LuaLoader.java:2236)
Mi A1: 	com.ansca.corona.JavaToNativeShim.nativeRender(Native Method)
Mi A1: 	com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:205)
Mi A1: 	com.ansca.corona.Controller.updateRuntimeState(Controller.java:364)
Mi A1: 	com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:434)
Mi A1: 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1625)
Mi A1: 	com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1380)
Mi A1: stack traceback:
Mi A1: 	[C]: ?
Mi A1: 	[C]: in function 'OpenOverlay'
Mi A1: 	?: in function <?:87>