简体   繁体   English

Android Studio清单合并失败minSdkVersion错误

[英]Android Studio Manifest merger failed minSdkVersion Error

I am trying to add a dependency in my app which has the minimum sdk version newer than my apps so I am getting the following error 我试图在我的应用程序中添加一个依赖项,该依赖项的sdk版本比我的应用程序新,因此我遇到以下错误

Error:Execution failed for task ':app:processDebugManifest'. 错误:任务':app:processDebugManifest'的执行失败。

Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library Suggestion: use tools:overrideLibrary="com.nononsenseapps.filepicker" to force usage 清单合并失败:uses-sdk:minSdkVersion 9不能小于库中声明的版本14建议:使用tools:overrideLibrary =“ com.nononsenseapps.filepicker”强制使用

but I don't know where to add that suggestion so I can build it. 但我不知道在何处添加该建议,因此我可以建立它。 This is how my build.gradle(Module: app) looks right now 这就是我的build.gradle(Module:app)现在的样子

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.codedspycamera.android"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.nononsenseapps:filepicker:+'
compile 'com.squareup.picasso:picasso:2.4.0'


}

com.nononsenseapps.filepicker works only on >=14 version android device. com.nononsenseapps.filepicker仅适用于> = 14版本的android设备。 I think it will crash if you force it to work on <14 devices. 我认为如果您强制它在<14个设备上运行,它将崩溃。 But anyway if you want to do this, you should force using minSdkVersion params from your main app to override library value. 但是无论如何,如果要执行此操作,则应从主应用程序强制使用minSdkVersion参数来覆盖库值。 Add suggested line to main app manifest. 向主应用清单添加建议行。 Read this for more information. 阅读此以获得更多信息。

Just to make the answer more clear for everyone this is what you have to do 只是为了使每个人都更清楚答案,这就是您要做的

tools:overrideLibrary marker 工具:覆盖库标记

A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version. 一个特殊标记,只能与uses-sdk声明一起使用,以覆盖导入其最低SDK版本比该应用程序的最低SDK版本新的库。 Without such a marker, the manifest merger will fail. 没有这样的标记,清单合并将失败。 The marker will allow users to select which libraries can be imported ignoring the minimum SDK version. 该标记将允许用户选择要导入的库,而无需考虑最低的SDK版本。

Example, In the main android manifest : 例如,在主要的Android清单中:

 <uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
          tools:overrideLibrary="com.example.lib1, com.example.lib2"/>

will allow the library with the following manifest to be imported without error : 将允许导入具有以下清单的库而不会出现错误:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.lib1">
    <uses-sdk android:minSdkVersion="4" />
</manifest> 

Note that the if multiple libraries are added than they must be separated with a comma "," 请注意,如果添加了多个库,则必须使用逗号“,”将它们分开。

For ionic developers 对于离子显影剂

config.xml - add - config.xml-添加-

 <preference name="android-minSdkVersion" value="19" />

bundle.gradle - add bundle.gradle-添加

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM