Solve the problem that the Android project cannot compile successfully due to calling the dependent library lib/sdk/api whose version is higher than minSdkVersion

Problem Description

In the AndroidStudio project, in order to avoid reinventing the wheel, it is often necessary to introduce some dependent libraries, but sometimes the imported dependent libraries are higher than the project minSdkVersion. At this time, the project will not compile successfully, and the following error will be reported.

Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 24 declared in library [:sdk-release:] /Users/dvlee/.gradle/caches/transforms-2/files-2.1/5c4b5f1d6ae801e31789a46703d1d014/sdk-release/AndroidManifest.xml as the library might be using APIs not available in 19
	Suggestion: use a compatible library with a minSdk of at most 19,
		or increase this project's minSdk version to at least 24,
		or use tools:overrideLibrary="cn.hidavid.lecelib" to force usage (may lead to runtime failures)

In fact, the solution has been clearly explained in the error, and I will describe it below.

Approach

Add in project AndroidManifest

<uses-sdk tools:overrideLibrary="cn.hidavid.lecelib"/>

If there are multiple such dependent libraries in the project, you can separate the package names with commas, such as:

<uses-sdk tools:overrideLibrary="cn.hidavid.lecelib,cn.hidavid.haha,cn.hidavid.hehe"/>

Guess you like

Origin blog.csdn.net/killfunst/article/details/110356872