Reputation: 1
I'm currently setting up Detox in my react-native app according to the steps listed here (https://wix.github.io/Detox/docs/introduction/project-setup). Once I actually run the build command though (detox build --configuration android.emu.debug), the terminal will fire an error saying that the build is unable to complete because of two dependencies from google firebase, analytics and crashalytics.
The error is as follows:
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugAndroidTestJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugAndroidTestCompileClasspath'.
> Could not find com.google.firebase:firebase-analytics:.
Required by:
project :app
> Could not find com.google.firebase:firebase-crashlytics:.
Required by:
project :app
However, I've looked at both of my build.gradle files and everything regarding firebase seems to be correct. The build only fails when I run the detox build script; when I run the build script within my package.json the app can still be built without issues. Here is my android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = '33.0.0'
minSdkVersion = 23
compileSdkVersion = 33
targetSdkVersion = 33
kotlinVersion = '1.8.0' // Update this to your version under Plugins => Kotlin
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
// RNMapboxMapsLibs = {
// implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1'
// implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.8.0'
// implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.8.0'
// implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0'
// }
// RNMapboxMapsPlugins = {
// implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0'
// implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.14.0'
// implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
// }
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('com.google.gms:google-services:4.3.15')
classpath('com.google.firebase:firebase-crashlytics-gradle:2.9.2')
classpath('com.google.firebase:perf-plugin:1.4.1')
}
}
allprojects {
repositories {
google()
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ''
}
}
}
}
The necessary classpaths and repositories are added. Then there's the android/app/build.gradle file:
apply plugin: 'kotlin-android'
apply plugin: 'com.android.application'
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
/**
*This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}
project.ext.vectoricons = [
iconFontNames: ['MaterialCommunityIcons.ttf'] // Add fonts needed
]
apply from: '../../node_modules/react-native-vector-icons/fonts.gradle'
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.chlela.perimeter"
defaultConfig {
applicationId 'com.chlela.perimeter'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 173
versionName "1.31"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
// Needed for auth0 library
manifestPlaceholders = [auth0Domain: 'perimeter.auth0.com', auth0Scheme: "${applicationId}.auth0"]
// Needed by react-native-screens library (maybe vector icons too)
vectorDrawables.useSupportLibrary true
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
/* Add the firebaseCrashlytics extension (by default,
* it's disabled to improve build speeds) and set
* nativeSymbolUploadEnabled to true along with a pointer to native libs. */
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
}
}
}
}
dependencies {
androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.4.2'
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${rootProject.ext.kotlinVersion}"
// Add the Firebase SDK for Google Analytics and Crashlytics
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
// All fresco packages should use the same version
if (isGifEnabled) {
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
// For animated gif support
implementation 'com.facebook.fresco:animated-gif:2.6.0'
}
}
// This method of including other gradle files is to support symlinks.
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project);
Again, the firebase implementations are added and the plugins at the top of the file are correct. I'm not sure why the detox build command is failing to resolve these dependencies; since the setup seems to be correct as indicated by the normal build script working, could the problem be a clash between firebase and detox?
Upvotes: 0
Views: 72