diff --git a/detox/test/android/app/build.gradle b/detox/test/android/app/build.gradle index 30858e59d7..4a78b93713 100644 --- a/detox/test/android/app/build.gradle +++ b/detox/test/android/app/build.gradle @@ -26,6 +26,16 @@ android { */ } + productFlavors { + flavorDimensions "compileRNFromSource" + fromSource { + dimension "compileRNFromSource" + } + fromBin { + dimension "compileRNFromSource" + } + } + signingConfigs { release { storeFile file("keystore.jks") @@ -51,7 +61,9 @@ android { dependencies { implementation "com.android.support:appcompat-v7:27.0.2" - implementation "com.facebook.react:react-native:+" // From node_modules + + fromSourceImplementation(project(path: ":ReactAndroid")) + fromBinImplementation "com.facebook.react:react-native:+" androidTestImplementation(project(path: ":detox")) androidTestImplementation 'junit:junit:4.12' diff --git a/detox/test/android/build.gradle b/detox/test/android/build.gradle index 8f3a5f42a7..787881f4c4 100644 --- a/detox/test/android/build.gradle +++ b/detox/test/android/build.gradle @@ -5,6 +5,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'de.undercouch:gradle-download-task:3.1.2' } } diff --git a/detox/test/android/settings.gradle b/detox/test/android/settings.gradle index b63d44f9cf..55be9788c1 100644 --- a/detox/test/android/settings.gradle +++ b/detox/test/android/settings.gradle @@ -3,4 +3,7 @@ rootProject.name = 'DetoxTest' include ':app' include ':detox' -project(':detox').projectDir = new File(rootProject.projectDir, '../../android/detox') \ No newline at end of file +project(':detox').projectDir = new File(rootProject.projectDir, '../../android/detox') + +include ':ReactAndroid' +project(':ReactAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/ReactAndroid') \ No newline at end of file diff --git a/detox/test/package.json b/detox/test/package.json index 1f49208d63..307fc17fb5 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -51,13 +51,19 @@ }, "android.emu.debug": { "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", - "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..", + "build": "cd android && ./gradlew assembleFromBinDebug assembleAndroidTest -DtestBuildType=debug && cd ..", "type": "android.emulator", "name": "Nexus_5X_API_26" }, "android.emu.release": { "binaryPath": "android/app/build/outputs/apk/release/app-release.apk", - "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..", + "build": "cd android && ./gradlew assembleFromBinRelease assembleAndroidTest -DtestBuildType=release && cd ..", + "type": "android.emulator", + "name": "Nexus_5X_API_26" + }, + "android.emu.debug.fromSource": { + "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", + "build": "cd android && ./gradlew assembleFromSourceDebug assembleAndroidTest -DtestBuildType=debug && cd ..", "type": "android.emulator", "name": "Nexus_5X_API_26" } diff --git a/docs/Guide.Contributing.md b/docs/Guide.Contributing.md index b0fb7300b5..80db052f6a 100644 --- a/docs/Guide.Contributing.md +++ b/docs/Guide.Contributing.md @@ -104,6 +104,22 @@ npm run build:android npm run e2e:android ``` +Android test project includes two flavors: +`fromBin` - uses the precompiled aar from `node_moudles` just like a standard RN project. +`fromSource` - compiles the project with RN sources from `node_modules`, this is useful when developing and debugging Espresso idle resource. +[Here](https://facebook.github.io/react-native/docs/building-from-source.html#android) are the prerequisites to compiling React Native from source. + +Each build can be triggered separately by running its assemble task: +`./gradlew assembleFromSourceDebug` or `./gradlew assembleFromBinDebug`. + +To run from Android Studio, React native `react.gradle` script requires `node` to be in path. +on macOS environment variables can be exported to desktop applications by adding the following to your `.bashrc`/`.zshrc`: + +```sh +launchctl setenv PATH $PATH +``` + + ### 3. Android Native tests 0. Install Java and Android SDK 25