expo: Clean expo init & prebuild can not build in Android Studio
Summary
Trying to init a new project and then prebuild it to access native code seems impossible. I want to run gradle tasks or open the project in Android Studio but seem to stumble on 2 failures:
> Configure project :app
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.
> Configure project :expo
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/thibault.maekelbergh/Downloads/temp/node_modules/expo/android/build.gradle' line: 9
* What went wrong:
A problem occurred evaluating project ':expo'.
> Cannot invoke method multiply() on null object
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* Where:
Build file '/Users/thibault.maekelbergh/Downloads/temp/node_modules/expo/android/build.gradle' line: 79
* What went wrong:
A problem occurred configuring project ':expo'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
What platform(s) does this occur on?
Android
SDK Version
45
Environment
expo-env-info 1.0.4 environment info:
System:
OS: macOS 12.3.1
Shell: 5.9 - /usr/local/bin/zsh
Binaries:
Node: 16.13.2 - ~/.asdf/installs/nodejs/16.13.2/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.1.2 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2022.06.27.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /Users/thibault.maekelbergh/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 23, 26, 27, 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.2
System Images: android-24 | Intel x86 Atom_64, android-28 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64
Android NDK: 20.1.5948944
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
npmPackages:
expo: ~45.0.0 => 45.0.6
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-web: 0.17.7 => 0.17.7
npmGlobalPackages:
eas-cli: 0.47.0
expo-cli: 5.4.12
Expo Workflow: bare
I use Java via asdf, tried with zulu-11.56.19, zulu-11.54.25, temurin-17.0.2+8 and updated the Android Studio Gradle JDK path accordingly each time.
Reproducible demo
Create new project:
$ expo init -t expo-template-blank-typescript . --npm
$ expo prebuild
Any of these trigger the errors:
- Run
expo run:android - Open in Android Studio (
open -a Android\ Studio ./android) and running a Gradle sync - Or try:
cd android && ./gradlew clean
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 44 (10 by maintainers)
Commits related to this issue
- build(gradle): fix build error See: https://github.com/expo/expo/issues/18129 — committed to coopcycle/coopcycle-app by r0xsh 2 years ago
- build(gradle): fix build error See: https://github.com/expo/expo/issues/18129 — committed to coopcycle/coopcycle-app by r0xsh 2 years ago
- build(gradle): fix build error See: https://github.com/expo/expo/issues/18129 — committed to coopcycle/coopcycle-app by r0xsh 2 years ago
- build(gradle): fix build error See: https://github.com/expo/expo/issues/18129 — committed to coopcycle/coopcycle-app by r0xsh 2 years ago
- build(gradle): fix build error See: https://github.com/expo/expo/issues/18129 — committed to coopcycle/coopcycle-app by r0xsh 2 years ago
@brentvatne it is working after I restart my laptop without changing anything. 🎉
weird, but it works now 😅
This workaround worked for me, but I didn’t like the idea of hardcoding the value, so I came up with this!
Temporary fix is to add the
reactNativeVersionproperty to your project build.gradle file. For example beneath thecompileSdkVersion.I am having similar issue with expo 48
tried all the above solution and nothing works
This also worked for me (but with 0.68.2). Thanks, was struggling for some hours already.
This worked for me perfectly! Thank you.
Using
expo@47.0.12andreact-native@0.70.5Confirmed that this workaround works for now. This shouldn’t really be necessary however, Expo should be able to figure out the react-native version by the package.json or similar
@thibmaek it’s strange. let’s investigate what happens to the node command execution first. could you apply the patch to
node_modules/expo/android/build.gradle? if there’s command execution errors, gradle should throw a GradleException and let you know the error message.