Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detox build fails on Android: Error while dexing

I can't get past detox build on a brand new Expokit project. The build fails on these tasks:

> Transform full.jar (project :unimodules-core) with DexingTransform
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): java.util.List org.unimodules.core.interfaces.Package.createExportedModules(android.content.Context)","sources":[{}],"tool":"D8"}

> Task :expo-font:mergeLibDexDebugAndroidTest FAILED
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): java.util.List org.unimodules.core.interfaces.Package.createExportedModules(android.content.Context)","sources":[{}],"tool":"D8"}

> Task :expo-linear-gradient:mergeLibDexDebugAndroidTest FAILED
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): java.util.List org.unimodules.core.interfaces.Package.createExportedModules(android.content.Context)","sources":[{}],"tool":"D8"}

> Task :expo-app-loader-provider:mergeLibDexDebugAndroidTest FAILED
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): java.util.List org.unimodules.core.interfaces.Package.createExportedModules(android.content.Context)","sources":[{}],"tool":"D8"}

> Task :expo-constants:mergeLibDexDebugAndroidTest FAILED
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): java.util.List org.unimodules.core.interfaces.Package.createExportedModules(android.content.Context)","sources":[{}],"tool":"D8"}

FAILURE: Build completed with 4 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':expo-font:debugAndroidTestRuntimeClasspath'.
> Failed to transform file 'full.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} using transform DexingTransform
   > Error while dexing.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':expo-linear-gradient:debugAndroidTestRuntimeClasspath'.
> Failed to transform file 'full.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} using transform DexingTransform
   > Error while dexing.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

3: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':expo-app-loader-provider:debugAndroidTestRuntimeClasspath'.
> Failed to transform file 'full.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} using transform DexingTransform
   > Error while dexing.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

4: Task failed with an exception.
-----------
* What went wrong:
Could not resolve all files for configuration ':expo-constants:debugAndroidTestRuntimeClasspath'.
> Failed to transform file 'full.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=21} using transform DexingTransform
   > Error while dexing.

Here's my config (works fine on iOS):

"detox": {
  "configurations": {
    "ios.sim.debug": {
      "binaryPath": "/Users/clementdebellefroid/Library/Developer/Xcode/DerivedData/detox-test-bdznjcaewoobdcfdwtdisdwidhjo/Build/Products/Debug-iphonesimulator/detox-test.app",
      "build": "xcodebuild -workspace ios/detox-test.xcworkspace -scheme detox-test -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
      "type": "ios.simulator",
      "name": "iPhone SE"
    },
    "android.device.debug": {
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
      "type": "android.attached",
      "name": "HYF0219402003939"
    }
  },
  "test-runner": "jest"
},

Reproduce

  1. Run expo init to create a new project
  2. Run expo eject make it an expokit project
  3. cd into your project, run yarn && cd ios && pod install
  4. Follow the steps to configure detox
  5. Add the android.device.debug config
  6. Run detox build -c android.device.debug

Here's a repo to help reproduce the issue: https://github.com/clems36/detox-test

Environment:

  • Detox: 14.0.3
  • React Native: 0.59.8
  • Node: v12.9.0
  • macOS: Mojave 10.14.6

This might not be directly related to Detox but i assume it affects anyone who creates an expokit project.

like image 305
clems36 Avatar asked Aug 30 '19 08:08

clems36


1 Answers

I faced the same issue and was able to solve it by limiting the gradlew tasks to the app project.

package.json:

  ...
  "detox": {
    "configurations": {
      ...
      "android": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "Nexus_5X_API_26"
      }
    },
    ...
  }
like image 176
Cyril Limam Avatar answered Oct 19 '22 23:10

Cyril Limam