diff --git a/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template b/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template index d603781238cfa..f208e83ba5aa0 100644 --- a/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/app/build.gradle.template @@ -147,6 +147,7 @@ android { <% if (e2eTestRunner === 'detox') { %> testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + missingDimensionStrategy 'detox', 'full' <% } %> if (isNewArchitectureEnabled()) { @@ -302,7 +303,7 @@ dependencies { } <% if (e2eTestRunner === 'detox') { %> - androidTestImplementation('com.wix:detox:+') + androidTestImplementation(project(path: ":detox")) <% } %> } diff --git a/packages/react-native/src/generators/application/files/app/android/build.gradle.template b/packages/react-native/src/generators/application/files/app/android/build.gradle.template index 66f622fccdc85..ef33f2c6d8b48 100644 --- a/packages/react-native/src/generators/application/files/app/android/build.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/build.gradle.template @@ -8,6 +8,9 @@ buildscript { minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 + <% if (e2eTestRunner === 'detox') { %> + kotlinVersion = '1.6.21' + <% } %> if (System.properties['os.arch'] == "aarch64") { // For M1 Users we need to use the NDK 24 which added support for aarch64 @@ -25,6 +28,9 @@ buildscript { classpath("com.android.tools.build:gradle:7.0.4") classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:4.1.2") + <% if (e2eTestRunner === 'detox') { %> + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + <% } %> // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -49,12 +55,5 @@ allprojects { } google() maven { url 'https://www.jitpack.io' } - - <% if (e2eTestRunner === 'detox') { %> - maven { - // All of Detox' artifacts are provided via the npm module - url "$rootDir/../node_modules/detox/Detox-android" - } - <% } %> } } diff --git a/packages/react-native/src/generators/application/files/app/android/settings.gradle.template b/packages/react-native/src/generators/application/files/app/android/settings.gradle.template index a507035c15027..e1644ef15c704 100644 --- a/packages/react-native/src/generators/application/files/app/android/settings.gradle.template +++ b/packages/react-native/src/generators/application/files/app/android/settings.gradle.template @@ -3,6 +3,11 @@ rootProject.name = '<%= className %>' include ':react-native-config' project(':react-native-config').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-config/android') +<% if (e2eTestRunner === 'detox') { %> +include ':detox' +project(':detox').projectDir = new File(rootProject.projectDir, '../node_modules/detox/android/detox') +<% } %> + apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)