Skip to content

Commit

Permalink
(Android) Introduce a fix/troubleshooting doc for issues with conflic…
Browse files Browse the repository at this point in the history
…ting kotlin stdlib flavours
  • Loading branch information
d4vidi committed May 2, 2019
1 parent b30ef59 commit 29b7b44
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
3 changes: 1 addition & 2 deletions detox/android/detox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 18
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 25
def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion : '1.3.0'

android {
compileSdkVersion _compileSdkVersion
Expand Down Expand Up @@ -58,7 +57,7 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$_kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.0"

// noinspection GradleDynamicVersion
compileOnly 'com.facebook.react:react-native:+'
Expand Down
1 change: 0 additions & 1 deletion detox/test/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
buildscript {
ext.kotlinVersion = '1.3.0'
ext.detoxKotlinVerion = ext.kotlinVersion
ext.buildToolsVersion = '27.0.3'

repositories {
Expand Down
28 changes: 19 additions & 9 deletions docs/Introduction.Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Please be aware that the `minSdkVersion` needs to be at least 18.

### 3. Add Kotlin

If your project does not already use Kotlin, add the Kotlin Gradle-plugin to your classpath in `android/build.gradle`:
If your project does not already support Kotlin, add the Kotlin Gradle-plugin to your classpath in the root build-script (i.e.`android/build.gradle`):

```groovy
buildscript {
Expand All @@ -102,14 +102,6 @@ buildscript {
_Note: most guides advise of defining a global `kotlinVersion` constant - as in this example, but that is not mandatory._


**IMPORTANT:** Detox aims at a playing fair with your app, and so it allows you to explicitly define the kotlin version for it to use - so as to align it with your own; Please do so - in your root `android/build.gradle` configuration file:

```groovy
buildscript {
ext.kotlinVersion = '1.3.0' // Your app's version
ext.detoxKotlinVersion = ext.kotlinVersion // Detox' version: should be 1.1.0 or higher!
}
```

***Note that Detox has been tested for version 1.1.0 of Kotlin, and higher!***

Expand Down Expand Up @@ -207,6 +199,24 @@ packagingOptions {



### Problem: Kotlin stdlib version conflicts

Of all [Kotlin implementation flavours](https://kotlinlang.org/docs/reference/using-gradle.html#configuring-dependencies), Detox assumes the most recent one, namely `kotlin-stdlib-jdk8`. If your Android build fails due to conflicts with implementations coming from other dependencies or even your own app, consider adding an exclusion to either the "other" dependencies or detox itself, for example:

```diff
dependencies {
- androidTestImplementation('com.wix:detox:+') { transitive = true }
+ androidTestImplementation('com.wix:detox:+') {
+ transitive = true
+ exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
+ }
}
```

Detox should work with `kotlin-stdlib-jdk7`, as well.



## Setting Detox up as a compiling dependency

This is an **alternative** to the setup process described under the previous section, on adding Detox as a dependency.
Expand Down

0 comments on commit 29b7b44

Please sign in to comment.