gluonhq / gluonfx-maven-plugin

Plugin that simplifies creating native images for Java/JavaFX maven projects
BSD 3-Clause "New" or "Revised" License
186 stars 38 forks source link

Disabling debugging in AAB not working #479

Open makingthematrix opened 12 months ago

makingthematrix commented 12 months ago

Hi, The problem might be on my side but I ran out of options. Maybe you can help me out.

I'm working on an Android app built with GraalVM Native Image + Gluon Mobile: FxCalculator. To publish it in Google Play Store, I need to disable debugging. I have a custom AndroidManifest.xml file in src/res/AndroidManifest.xml where I added android:debuggable="false" to the <application> tag, but it seems to does nothing. After building AAB, signing it, and uploading to Google Console, I'm getting an error that the debbuging is still enabled.

I searched Google and Stack Overflow, looking for other ways, but all I find is either about setting "debuggable" to false in AndroidManifest.xml, or about setting tags in pom.xml but in a way that doesn't work in my case. I tried to add tags like <debuggable>false</debuggable> and <release>true</release>, and a few others to my pom.xml in a few places: in main properties, in the Android profile, and in <releaseConfiguration> in the gluonfx-maven-plugin` settings, but they either do nothing or are simply not accepted. I also looked trought the code of gluonfx-maven-plugin and substrate, and I can't find anything that could help me.

Any hints?

notdebuggable

tiainen commented 12 months ago

Have a look at the docs that explains the configuration of the maven plugin: https://docs.gluonhq.com/#_configuration and especially the section on releaseConfiguration: https://docs.gluonhq.com/#_release_configuration

makingthematrix commented 12 months ago

@tiainen : The docs don't really explain much, but thanks to your comment, I looked again to pom.xml, tried a few things at random, and at one moment something in the logs caught my eye:

[SEVERE] The key store path <path> is not valid. Using Debug signing configuration

So I looked into the substrate plugin source code and found out that if the signing data is not passed properly, mvn gluonfx:package does not fail, but just switches to the debug mode. Even if I properly sign it later with an external tool, it's still a debuggable app and Google doesn't accept it. Only when I signed the app in the way the plugin wanted, it packaged my app in the release mode (there's no way to tell the plugin explicitly that I want the release mode).

I believe this is bad design. I would much prefer the packaging to fail and tell me what's wrong exactly. I can open a PR in substrate and do it in a way that wouldn't break backward compatibility. For example, there could be a new flag in ReleaseConfiguration called forceRelease, by default set to false. Only when set to true, it would change the logic, and also allow to package the app in the release mode without signing (if the signing data was missing - but not when it's invalid).

What do you think?