Unable to build for Android

I’m unable to build my app for Android.
I write code. I’m not familiar with all the exotics around which version of what command line app needs to run at what time, or step. So, I’m reduced to following instructions.
Google tells me that my app store apps need to be upgraded to target a newer SDK version. So, trying to achieve this, here’s my shopping list of problems.

When I try to run meteor update, I am presented with this:

Error: incorrect data check
at Zlib.zlibOnError [as onerror] (zlib.js:187:17)
=> awaited here:
at Promise.await (/Users/{{me}}/.meteor/packages/meteor-tool/.2.13.0.1iwqaqu.34uuk++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:60:12)

meteor --version tells me I’m at 2.5.1.

However, I don’t necessarily need to run the latest version. So, I just try meteor build --server=http://localhost:3000 ../../first.

This does a lot of crunching, but fails with notices including…

FAILURE: Build failed with an exception. -

Building Cordova app for Android \

  • What went wrong:

Execution failed for task ‘:app:processReleaseMainManifest’.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not “opens java.io” to unnamed module @187a9d9

  • 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
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

But, running with --stacktrace tells me it’s an ‘unknown option’.

Googling suggests I’m dealing with some Java issue. I install java 16 and add lines to .zshrc. This, so that echo $JAV_HOME now gets me:

/Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk/Contents/Home

This folder exists on my machine.

But, the build still fails after that.

I then turn to a build process that involves Android Studio, as mentioned here:

I used this in the past, but this process fails early on, as “Generate Signed Bundle / APK” is not an option under “Build” for me.

Then I figure I should go back to the source, at:

Meteor!

So, I run meteor install-sdk android. This tells me to look at:

This leads to brew install gradle, which leads to:

Cannot install in Homebrew on ARM processor in Intel default prefix

Which leads to brew bundle dump, which finishes without a notification. Did that do the trick? I earlier had an issue around Gradle. So… maybe?

Running the build again, I get the same error as before. So, maybe not.

So now I just throw /opt/homebrew in the bin, and try to brew install gradle again. But this gives me the same error. I look at ““Alternative Installs” from: Installation — Homebrew Documentation”, but this is abracadabra to me.

I try to uninstall homebrew, which resulted in “Homebrew partially uninstalled (but there were steps that failed)!”.

I install Homebrew again. This works.
I run brew install gradle again. This works.
I try my build again. But the failure is the same:

FAILURE: Build failed with an exception. \

  • What went wrong:

Execution failed for task ‘:app:processReleaseMainManifest’.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not “opens java.io” to unnamed module @187a9d9

  • 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.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

I just want an APK. Or that fancy new package format (aab?).

What do I need to do to make this happen?

This information has nothing to do though with your errors

Meteor 2.5.1 seems to work on Cordova Android 10 https://github.com/meteor/meteor/blob/devel/docs/history.md#meteor-version-release-21

You can target maximum API 30 for Android: Android Platform Guide - Apache Cordova This table was not updated for Cordova Android 12 which has been out for some time now.

However, now you need at least API 33 in order to publish an app with Google Play: Target API level requirements for Google Play apps - Play Console Help.

I’m pretty sure jdk16 is not compatible, and you need to use jdk11.
Let me know if it worked.

Thanks @paulishca. Google states that for existing apps, the target can be API 31, but if I read your linked info correctly, that will still not be available to me, using Meteor 2.5.1.
So, this means that, as long as I use 2.5.1, I can not push a new version to Google Play, even if I manage to put together a build, right?

Thanks @bordalix. All this suggests to me that there’s room for a standalone app which, at the push of a button, builds a Meteor app to an uploadable app, using the right build tools :confused:

I had jdk11 already installed on my system. I updated .zshrc to include:

export JAVA_HOME=“/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home”
export PATH=“$JAVA_HOME/bin:$PATH”}

But, then restarting a terminal session and running echo $JAV_HOME gets me no output. Well, an empty line.

Just for good measure, I tried reinstalling jdk11.0.19 from a .dmg, but this presents me with the message that “A newer update already exists”, and then refuses to install.
Instead, copying the idk from a compressed archive allows me to put the files in my Library.

I update .zshrc again, restart my terminal, and again for echo $JAV_HOME get an empty line as response.

Stuck again :confused:

This is my shell script to build my Android app.
I’ve just run it and uploaded the app to Play Store.
I’m running a Mac with Apple silicon.

# brew install openjdk@11
# brew install gradle
# install android studio

export JAVA_HOME=/opt/homebrew/opt/openjdk@11
export ANDROID_HOME=$HOME/Library/Android/sdk
export BUILD_TOOLS_VERSION=30.0.3
export TOOLS_PATH=$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION

# if you want a .aab file, remove packageType option
meteor build ../builds --packageType=apk --server https://wheretosurftoday.com --mobile-settings settings.json;

cd .meteor/local/cordova-build/platforms/android/app/build/outputs/apk/release

$TOOLS_PATH/zipalign 4 app-release-unsigned.apk unsigned.apk
$TOOLS_PATH/apksigner sign --ks ~/.keystore --ks-key-alias WhereToSurfToday --out signed.apk unsigned.apk
$TOOLS_PATH/apksigner verify signed.apk

mv signed.apk ~/Desktop/WhereToSurfToday-2023082901.apk
rm app-release-unsigned.apk unsigned.apk

Hope it helps.

Thanks again, @bordalix.

What I notice is that you use brew to install jdk. I now did this, too, then found my gradle was already at the latest release, and when trying to build, got presentation with a new error. Progress!

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 <activity>  |  Android Developers for details.

Inspired by this thread, I added this to my mobile-config.js:

App.appendToConfig(`
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity" xmlns:android="http://schemas.android.com/apk/res/android">
   <activity android:exported="false"/>
</edit-config>`);

And, that gave me a build! And using your build command, it gave me an .apk! Which I could sign and zipalign!

Uploading to Google Play got me this:

Error from apksigner: ERROR: MIN_SIG_SCHEME_FOR_TARGET_SDK_NOT_MET: Target SDK version 33 requires a minimum of signature scheme v2; the APK is not signed with this or a later signature scheme

This error includes a link which points to this page, which is all about Android Studio.

I first remembered that I had gone through something similar before, and re-found this page. But, importing the build into Android Studio returns this:

Directory ‘/Users/{{me}}/first/android’ does not contain a Gradle build.

Then, I noticed that you, @bordalix, first zipalign, and then use something that’s apksigner.

I first do this:

~/Library/Android/sdk/build-tools/30.0.3/zipalign 4 app-release-unsigned.apk unsigned.apk

Then this:

~/Library/Android/sdk/build-tools/30.0.3/apksigner sign --ks ~/.keystore --ks-key-alias {{my-app}} --out signed.apk unsigned.apk

And I have a, presumably, zipaligned and signed .apk.

Google Play Console accepts it! There IS a god!

The app is now ‘in review’, and although I find Google Play’s interface a hot mess, I believe that signs point to that if this review is completed, the app will also be available in production.

Thanks again @bordalix, you got me on the right track.

But, why is this process so terribly difficult to get through.

I’m glad you made it :slight_smile:
And it was right on time :wink:

Thanks :slight_smile:

Though, I have to do this for four more apps. And, this first one was approved and, just now, made it into the App Store. But this version, downloaded from the App Store to my test device, just immediately crashes.

So… back to the drawing board.