I am working on a simple app with react native (/expo). When I do something as simple as just the following 4 commands (in order on a Windows 11, Expo 51):
npx create-expo-app Test --template
(selected the Blank
template; without Typescript)cd Test
npm install
npx expo run:android
I get the following output and error:
๐ Android package Learn more: https://expo.fyi/android-package
โ What would you like your Android package name to be? ... com.pmaddineedi.Test
โ Created native directory
โ Updated package.json
ยป android: userInterfaceStyle: Install expo-system-ui in your project to enable this feature.
โ Finished prebuild
โบ Building app...
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\pmadd\Mobile Development\Audacity\Test\android\settings.gradle' (C:\Users\pmadd\.gradle\caches\8.6\scripts\9jvl7af6mie02hkplgyjc1nfd).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66
* 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 758ms
Error: C:\Users\pmadd\Mobile Development\Audacity\Test\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
Error: C:\Users\pmadd\Mobile Development\Audacity\Test\android\gradlew.bat app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=x86_64,arm64-v8a exited with non-zero code: 1
at ChildProcess.completionListener (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\spawn-async\build\spawnAsync.js:42:23)
at Object.onceWrapper (node:events:634:26)
at ChildProcess.emit (node:events:519:28)
at cp.emit (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5)
...
at spawnAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\spawn-async\build\spawnAsync.js:7:23)
at spawnGradleAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:96:48)
at assembleAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\start\platforms\android\gradle.js:74:18)
at runAndroidAsync (C:\Users\pmadd\Mobile Development\Audacity\Test\node_modules\@expo\cli\build\src\run\android\runAndroidAsync.js:45:37)
However, npm start
works perfectly well.
How do I fix this?
Note that I have seen many solutions online to fix this issue, but none that I saw seem to work.
I am using java jdk 20, since it seems like I need 17+ and 22 is too new
Using gradle init
with the following input worked:
Type of Project: Application (2)
Implementation Language: Kotlin (4)
Generate multiple subprojects for application: no
Build Script DSL: Kotlin (1)
Target Java Version: 20
Generate build using new APIs and behavior: yes