错误提示:Suggestion: use tools:overrideLibrary="" to force usage

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Maiduoudo/article/details/83000069

异常提示:

应用在Android Studio Build的时候,抛出了如下异常:

Error:Execution failed for task ‘:app:processDebugManifest’.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [jp.wasabeef:blurry:1.0.0] /Users/xxx/xxx/app/build/intermediates/exploded-aar/jp.wasabeef/blurry/1.0.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary=”jp.wasabeef.blurry” to force usage

错误原因:

出现这个错误的原因是我引入的第三方库最低支持版本高于我的项目的最低支持版本,异常中的信息显示:我的项目的最低支持版本为8(Android 2.2),而第三方库的最低支持版本为9(Android 2.3),所以抛出了这个异常。

解决办法:

在AndroidManifest.xml文件中 标签中添加<uses-sdk tools:overrideLibrary="xxx.xxx.xxx"/>,其中的xxx.xxx.xxx为第三方库包名,如果存在多个库有此异常,则用逗号分割它们,例如:<uses-sdk tools:overrideLibrary="xxx.xxx.aaa, xxx.xxx.bbb"/>,这样做是为了项目中的AndroidManifest.xml和第三方库的AndroidManifest.xml合并时可以忽略最低版本限制。

  如下

AndroidManifest.xml添加: xmlns:tools=http://schemas.android.com/tools

添加后的代码如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.administrator.myapplication"
    tools:overrideLibrary="com.xys.libzxing">
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
 
</manifest>

即:

再次编译项目,即可成功编译。

参考链接:

http://blog.csdn.net/maosidiaoxian/article/details/42671999
http://stackoverflow.com/questions/27095077/how-do-i-use-toolsoverridelibrary-in-a-build-gradle-file
http://blog.csdn.net/b275518834/article/details/45557521

猜你喜欢

转载自blog.csdn.net/Maiduoudo/article/details/83000069