【问题标题】:Detox build fails on Android: Error while dexingAndroid 上的 Detox 构建失败:dexing 时出错
【发布时间】:2020-01-03 11:53:32
【问题描述】:

在全新的 Expokit 项目中,我无法通过 detox build。在这些任务上构建失败:

> 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.

这是我的配置(在 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"
},

复制

  1. 运行expo init创建一个新项目
  2. 运行 expo eject 使其成为一个 expokit 项目
  3. cd 进入你的项目,运行 yarn && cd ios && pod install
  4. Follow the steps to configure detox
  5. 添加android.device.debug 配置
  6. 运行detox build -c android.device.debug

这里有一个 repo 来帮助重现这个问题:https://github.com/clems36/detox-test

环境:

  • 排毒:14.0.3
  • 反应原生:0.59.8
  • 节点:v12.9.0
  • macOS:莫哈韦 10.14.6

这可能与 Detox 没有直接关系,但我认为它会影响任何创建 expokit 项目的人。

【问题讨论】:

    标签: android react-native expo detox


    【解决方案1】:

    我遇到了同样的问题,并且能够通过将 gradlew 任务限制到应用项目来解决它。

    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"
          }
        },
        ...
      }
    

    【讨论】:

    • 我不是 100% 确定为什么,但是 Cyril 指出的限制任务对我有用
    • Cyril 的建议,也解决了我的问题。
    • 也为我工作
    【解决方案2】:

    如果您可以根据@Cyril Limam 推荐的更改更改您的配置,您将避免在解决上述问题后您将面临的其他问题。

     "android.debug": {
          "type": "android.apk",
          "binaryPath": "android/app/build/outputs/apk/debug/app-x86-debug.apk",
          "testBinaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
          "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd .."
     }
    

    请确保 binaryPath 表示您的应用 APK 的路径,而 testBinaryPath 表示您的 androidTest APK 的路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-02
      • 2022-11-02
      • 2018-12-07
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多