Repository navigation
Conversation
The template's Gradle 8.14.5 can't run on Java 25, which is what Android Studio now bundles. Its Kotlin DSL compiler fails to parse the version and the only error is "What went wrong: 25.0.3". Move the template to Gradle 9.8.2, AGP 9.4.0 and Kotlin 2.4.21, and pin the JDK the Gradle daemon runs on (25) in gradle/gradle-daemon-jvm.properties. Gradle uses a matching local JDK or downloads that one, so a newer JAVA_HOME only has to start the launcher. AGP 9 has Kotlin built in, so the kotlin-android plugin and kotlinOptions go, and the generated plugin sources are registered as Kotlin sources. R8's stricter keep rules are held at the AGP 8 meaning for plugin rules. native:run and native:package now pick the Java to start Gradle with (NATIVEPHP_GRADLE_PATH, JAVA_HOME, Android Studio's JDK, then PATH), pass Android Studio's JDK to Gradle so the pin can match it, and stop early with a clear message when nothing fits or an older project can't run on the current Java. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds a fresh app's Android project with native:run on JDK 17, 21 and the latest JDK release, with the daemon JDK pin and without it, plus one leg on the newest Gradle release. Runs weekly and when the template or the Android build code changes, so a new JDK or Gradle release that breaks the template fails here first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android builds fail straight away when Gradle runs on Java 25, which is the JDK Android Studio bundles now (2026.2 ships JBR 25.0.3). The whole error is:
The template's Gradle 8.14.5 compiles the
.ktsbuild scripts with an embedded Kotlin 2.0.21 compiler, and that compiler throwsIllegalArgumentException: 25.0.3when it parses the running JVM's version. AGP never even loads. Anyone whoseJAVA_HOMEor default JDK is newer than the template's Gradle supports gets this, and the next JDK would do it again.Version moves
compileSdk, the NDK,
compileOptions(Java 17 bytecode) and every library version are unchanged.Keeping it working on future JDKs
The template now has
gradle/gradle-daemon-jvm.properties, which tells Gradle which JDK the daemon must run on. Gradle uses a matching JDK it finds locally, or downloads that one (Temurin, through the foojay URLs in the file) into~/.gradle/jdks.JAVA_HOMEthen only has to start the Gradle launcher, which works on any JDK 17 or newer. A new JDK on a developer's machine can't reach the code that broke here, because the build itself always runs on 25.I picked this over the alternatives because it's the one mechanism that covers every way the project gets built:
native:run,native:package,./gradlewby hand, Android Studio (which reads the same file, and since Panda uses it for new projects by default) and Bifrost. A version check innative:runalone would leave the others exposed, and Java toolchains for compiling don't help when the failure is Gradle's own script compiler.Why 25: it's the current LTS and what Android Studio ships, so most people already have it and nothing is downloaded. It's also the longest-lived choice if a future AGP or Gradle raises its minimum above 17.
The foojay resolver plugin isn't in
settings.gradle.kts. It's only needed to regenerate the URLs, so the file has a comment on how to do that. Nothing extra is resolved at build time.native:run and native:package
New
GradleJavapicks the Java that starts Gradle, in this order:NATIVEPHP_GRADLE_PATH(an existing config key that nothing read until now),JAVA_HOME, Android Studio's bundled JDK, thenjavaon the PATH. It skips anything older than 17.JAVA_HOME, Gradle is started with Android Studio's JDK. Before this, the build failed on this Mac because there's no Java on the PATH.-Dorg.gradle.java.installations.paths, because Gradle doesn't find it on its own. That lets the pin match it instead of downloading.nativephp/android(Gradle 8, no pin) and Java is 25 or newer,native:runnow stops in a second with "This Android project uses Gradle 8.14.5, which can't run on Java 25 (JAVA_HOME)" and tells you to runnative:install android.native:debugreports this Java instead of whateverjava -versionsays.AGP 9 changes in the template
org.jetbrains.kotlin.androidis gone, andkotlinOptionsbecomes a top-levelkotlin { compilerOptions {} }.jvmTargetnow followstargetCompatibility.java.srcDir, so the plugin compiler'ssrc/nativephp/kotlinroot is registered withkotlin.directories.registerPluginSourceRoot()still injectsjava.srcDirfor scaffolds that predate the root, which are all AGP 8.-keep class Xno longer keeps X's no-arg constructor.android.r8.strictFullModeForKeepRules=falsekeeps the old meaning for plugin andcustom_proguard_ruleskeep rules. The template and its first-party plugins also ran fine with strict mode on, so this can go once plugin rules are checked.shrink_resources, but those apps should check that resources looked up by name (the splash drawable, plugin sounds) survive.What an app has to do
Run
php artisan native:install androidagain. It replacesnativephp/androidwith the new template, so anything edited by hand in there is lost, as usual.Plugin authors: the
kotlin-kaptplugin doesn't work with built-in Kotlin (KSP does), and any Gradle plugin declared inandroid.gradle_pluginshas to support AGP 9. None of the first-party plugins use kapt. I haven't checkedcom.google.gms.google-services4.4.3 (the Firebase plugin) against AGP 9.CI
A second commit adds
.github/workflows/android-template.yml. The job makes a fresh Laravel app, installs this branch, and builds a minified release APK withnative:run, which runs AGP, Kotlin, CMake, lint and R8:"Latest" is looked up from Adoptium on each run. It runs weekly as well as on template changes, so a new JDK or Gradle release that breaks the template fails there first. It uses
ubuntu-latestand installs SDK 36 withsdkmanager, so it doesn't have the SDK 34 problem that parkedtest-package.yml.Verified
On an Android emulator (API 35, arm64), with a fresh
native:install androidof this branch into mobile-starter (mobile-ui and mobile-browser installed), each a clean build that installed and launched:JAVA_HOME= Android Studio's JBR 25.0.3JAVA_HOME= Temurin 21, daemon on the pinned 25JAVA_HOME= Temurin 27, daemon on the pinned 25JAVA_HOMEand no Java on the PATH (picked Android Studio's JDK)profileablebuild (R8 ran, 7.9 MB of dex), with the keep-rule opt-out and with strict mode, rendering the starter screenThe old template (Gradle 8.14.5) on JBR 25 reproduced the original error. The package's tests pass (
vendor/bin/pest: 1584 passed), and the existing Tests, Static Analysis and Code Style checks pass on this PR.Worth watching
native:run's 600 second Gradle timeout (Don't stop Gradle after 600 seconds #500 removes it).updateBuildConfiguration()rewrites everyisMinifyEnabledinbuild.gradle.kts, including the profileable build type's hard-codedtrue. So profileable builds aren't minified unlessNATIVEPHP_ANDROID_MINIFY_ENABLEDis on.🤖 Generated with Claude Code