My EAS build is failing after adding expo-firebase-analytics
. I was able to fix the problem locally by opening the project in Android studio and making the following changes:
- Commented out ‘classifier’ line from /Users/me/Documents/MyApp/node_modules/expo-firebase-analytics/android/build.gradle
- Added to /Users/me/Documents/MyApp/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
@OptIn(kotlin.ExperimentalStdlibApi::class)
androidComponents.onVariants(androidComponents.selector().all()) { variant ->
- Set gradle in gradle-wrapper.properties to 7.5:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
The exact error I’m getting is:
Running 'gradlew :app:assembleDebug' in /home/expo/workingdir/build/android
Downloading https://services.gradle.org/distributions/gradle-8.0.1-all.zip
10%.
20%.
30%
40%
50%.
60%.
70%.
80%
90%.
100%
Welcome to Gradle 8.0.1!
Here are the highlights of this release:
- Improvements to the Kotlin DSL
- Fine-grained parallelism from the first build with configuration cache
- Configurable Gradle user home cache cleanup
For more details see https://docs.gradle.org/8.0.1/release-notes.html
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/8.0.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
> Task :expo-updates-gradle-plugin:pluginDescriptors
> Task :expo-updates-gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:pluginDescriptors
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:processResources
> Task :expo-dev-launcher-gradle-plugin:compileKotlin
> Task :expo-dev-launcher-gradle-plugin:compileJava NO-SOURCE
> Task :expo-dev-launcher-gradle-plugin:classes
> Task :expo-dev-launcher-gradle-plugin:jar
> Task :expo-dev-launcher-gradle-plugin:inspectClassesForKotlinIC
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC
> Task :expo-updates-gradle-plugin:compileKotlin
> Task :expo-updates-gradle-plugin:compileJava NO-SOURCE
> Task :expo-updates-gradle-plugin:classes
> Task :expo-updates-gradle-plugin:jar
> Task :expo-updates-gradle-plugin:inspectClassesForKotlinIC
> Configure project :app
ℹ️ Applying gradle plugin 'expo-dev-launcher-gradle-plugin' (expo-dev-launcher@2.4.12)
ℹ️ Applying gradle plugin 'expo-updates-gradle-plugin' (expo-updates@0.18.13)
> Configure project :expo-av
Checking the license for package NDK (Side by side) 23.1.7779620 in /home/expo/Android/Sdk/licenses
License for package NDK (Side by side) 23.1.7779620 accepted.
Preparing "Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)".
"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" ready.
Installing NDK (Side by side) 23.1.7779620 in /home/expo/Android/Sdk/ndk/23.1.7779620
"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" complete.
"Install NDK (Side by side) 23.1.7779620 (revision: 23.1.7779620)" finished.
Checking the license for package CMake 3.22.1 in /home/expo/Android/Sdk/licenses
License for package CMake 3.22.1 accepted.
Preparing "Install CMake 3.22.1 (revision: 3.22.1)".
"Install CMake 3.22.1 (revision: 3.22.1)" ready.
Installing CMake 3.22.1 in /home/expo/Android/Sdk/cmake/3.22.1
"Install CMake 3.22.1 (revision: 3.22.1)" complete.
"Install CMake 3.22.1 (revision: 3.22.1)" finished.
[stderr]
FAILURE: Build completed with 2 failures.
[stderr]
1: Task failed with an exception.
[stderr]
-----------
[stderr]
* Where:
[stderr]
Build file '/home/expo/workingdir/build/node_modules/expo-firebase-analytics/android/build.gradle' line: 40
[stderr]
* What went wrong:
[stderr]
A problem occurred evaluating project ':expo-firebase-analytics'.
[stderr]
> Could not set unknown property 'classifier' for task ':expo-firebase-analytics:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.
[stderr]
* Try:
[stderr]
> Run with --stacktrace option to get the stack trace.
[stderr]
> Run with --info or --debug option to get more log output.
[stderr]
> Run with --scan to get full insights.
[stderr]
==============================================================================
[stderr]
2: Task failed with an exception.
[stderr]
-----------
[stderr]
* What went wrong:
[stderr]
A problem occurred configuring project ':expo'.
[stderr]
> compileSdkVersion is not specified. Please add it to build.gradle
[stderr]
* Try:
[stderr]
> Run with --stacktrace option to get the stack trace.
[stderr]
> Run with --info or --debug option to get more log output.
[stderr]
> Run with --scan to get full insights.
[stderr]
==============================================================================
[stderr]
* Get more help at https://help.gradle.org
[stderr]
BUILD FAILED in 2m 39s
15 actionable tasks: 15 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
From what I can tell, the issue is with this line:
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
In the analytics plugin.
I also had to downgrade the packages to:
"@react-native-firebase/analytics": "15.4.0",
"@react-native-firebase/app": "15.4.0",
"@react-native-firebase/crashlytics": "15.4.0",
"@react-native-firebase/firestore": "15.4.0",
to get it to build locally.
However, as I mentioned, the build just works locally after manually setting the gradle version to 7.5.
What am I missing? Shouldn’t Firebase Analytics work out of the box? I would assume this issue would be widespread but I haven’t found anything on it so presumably I’m doing something wrong here.