gradle 使用minSdk最多为16的兼容库

ryoqjall  于 2023-08-06  发布在  其他
关注(0)|答案(2)|浏览(121)

嗨,我正在尝试建立排毒测试我的应用程序。我遇到了兼容性问题。我的应用程序运行Android版本21至31。我得到下面的错误,当我运行命令“yarn detox build -c android

错误:

任务:react-native-midnight:processDebugAndroidTestManifest FAILED [androidx.vectordrawable:vectordrawable-animated:1.0.0]/Users/user/. gradle/caches/transforms-2/files-2.1/5677f0d1d2fd33816116c626e2dd87f1/vectordrawable-animated-1.0.0/AndroidManifest. xml警告:包名'androidx.vectordrawable'用于:androidx.vectordrawable:vectordrawable-animated:1.0.0,androidx.vectordrawable:vectordrawable:1.0.1./Users/user/projects/MyWorkspaceapp/node_modules/react-native-midnight/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger10963475594834660155.xml:5:5-74错误:uses-sdk:minSdkVersion 16不能小于library中声明的version 21 [com.facebook.react:react-native:0.65.2]/Users/user/. gradle/caches/transforms-2/files-2.1/b7 e25968130290 bea 6922 f5 b 0 f7 f24 b 0/jetified-react-native-0.65.2/AndroidManifest. xml,因为library可能使用16中不可用的API建议:使用minSdk最多为16的兼容库,或将此项目的minSdk版本增加到至少21,或使用工具:overrideLibrary=“com.facebook.react”强制使用(可能导致运行时失败)
有关清单合并的更多信息,请参见http://g.co/androidstudio/manifest-merger

build.gradle:

ext {
    compileSdkVersion = 31
    targetSdkVersion = 31
    minSdkVersion = 21
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
//    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 31
        multiDexEnabled true
    }
}

字符串

AndroidManifest.xml

> <uses-sdk android:minSdkVersion="21"
>       android:targetSdkVersion="31"
>       android:maxSdkVersion="31"
>       tools:overrideLibrary="com.facebook.react" />

bcs8qyzn

bcs8qyzn1#

在build.gradle中添加下面一行。这很管用

subprojects { 
    ext {
        compileSdk = rootProject.ext.compileSdkVersion
        minSdk = rootProject.ext.minSdkVersion
        targetSdk = rootProject.ext.targetSdkVersion
    }
    afterEvaluate { subproject ->
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
                defaultConfig {
                    minSdkVersion rootProject.ext.minSdkVersion
                    targetSdkVersion rootProject.ext.targetSdkVersion
                }
            }
        }
    }
}

字符串

b91juud3

b91juud32#

尝试通过在.detoxrc.js文件中更改build命令来构建,如下所示,通过添加app:作为assembleDebugassembleAndroidTest的前缀

build: 'cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=Debug'

字符串
参考:https://github.com/wix/Detox/issues/2712#issuecomment-1458411754

相关问题