android - Android 上的 Detox 构建失败:dexing 时出错
问题描述
我无法通过detox build
一个全新的 Expokit 项目。构建在这些任务上失败:
> 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"
},
复制
- 运行
expo init
创建一个新项目 - 运行
expo eject
使其成为一个expokit项目 cd
进入你的项目,运行yarn && cd ios && pod install
- 按照步骤配置排毒
- 添加
android.device.debug
配置 - 跑
detox build -c android.device.debug
这是一个帮助重现问题的仓库:https ://github.com/clems36/detox-test
环境:
- 排毒:14.0.3
- 反应原生:0.59.8
- 节点:v12.9.0
- macOS:莫哈韦 10.14.6
这可能与 Detox 没有直接关系,但我认为它会影响任何创建 expokit 项目的人。
解决方案
我遇到了同样的问题,并且能够通过将 gradlew 任务限制到应用程序项目来解决它。
包.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"
}
},
...
}
推荐阅读
- python - 如何在一个字符串中找到字母,数字然后在python中放入换行符
- python - 使用scrapy提取带有标题和带有选定链接的url的链接
- html - 需要设计显示带有设置图标的 HTML (Div)
- mysql - 如何在一行中显示值字段但分开
- c# - 如何部分提取 JSON 字符串以按名称获取特定对象
- java - cache2k 是持久缓存吗?
- java - 如果应用程序实现 CommandLineRunner,则 Spring Batch 重试在 Java 中不起作用
- android - 如何自动化生物特征识别,如人脸识别和指纹?
- r - 如何在不重新安装的情况下更新本地创建的 R 包
- php - Laravel 5.2 安装错误:需要打开失败../vendor/autoload.php