Build faild in android uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library

i’m getting this error while i trying to build android

BUILD FAILED
 in 1s

(node:1880) UnhandledPromiseRejectionWarning: Error: /Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/build.gradle' line: 55

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'build' for root project 'android' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
    at ChildProcess.whenDone (/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:1880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1880) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

Hi, What is your command ?

ionic cordova build android
now i getting this error

:app:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
23 actionable tasks: 3 executed, 20 up-to-date
(node:3131) UnhandledPromiseRejectionWarning: Error: /Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/app/src/main/AndroidManifest.xml:27:5-74 Error:
        uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
    at ChildProcess.whenDone (/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:3131) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3131) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Have you already install Android Studio and Gradle android ? If not you need to do this and retry after that

i already installed them
now this error from android studio
43%20PM

Maybe you need to download SDK version 16 into SDK Manager of Android Studio ?

i have updated the sdk and still getting error

 UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/app/src/main/AndroidManifest.xml:27:5-74 Error:
        uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

:app:processDebugManifest FAILED
23 actionable tasks: 1 executed, 22 up-to-date
(node:4302) UnhandledPromiseRejectionWarning: Error: /Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/app/src/main/AndroidManifest.xml:27:5-74 Error:
        uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:tbxml-android:] /Users/anspireagency/.gradle/caches/transforms-1/files-1.1/tbxml-android.aar/3ed1ecc6627bfe7aa681fa1d0e6cfd6b/AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="za.co.twyst" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
    at ChildProcess.whenDone (/Users/anspireagency/Desktop/ahmed f/Doctory/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:4302) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4302) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Define <preference name="android-minSdkVersion" value="19" /> in config.xml file.

11 Likes

This is caused when you install google maps plugin. This is how I solved it:

  • run “ionic cordova platform rm android” to remove the android platform
  • edit android-minSdkVersion to reflect 19 in your config.xml
  • add android platform and it should work.
7 Likes

I uninstall ionic cordova plugin remove cordova-plugin-googlemaps and work version 16 (ionic cordova build android --prod)

Hey.
for the one of you who still struggle with this, i found out that the line
in config.xml file does not influence.
the solution i found is adding this: “-- – --minSdkVersion=21” to the build command like this:
ionic cordova build android --prod --release – -- --minSdkVersion=19

Hope it helps

2 Likes

thank you for reply
i will try it soon

it work for me… thanks

If I change it, dont generate the “outputs” folder and the unsigned-apk when i build :S

This works for me. Thank a lot.

Worked fine for me, thanks!

not work for me.
still shows the error
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:CordovaLib] /FOLDER_PROJECT/build\intermediates\manifests\full\debug\AndroidManifest.xml as the library might be using APIs not available in 16

Please post here the full build command, maybe there is some mistake.

Yosi

Number of hyphenes are not correct, there supposed to be 6 hyphenes before minSdkversion=21 command.

Try it out… it works…

My project has:
<preference name="android-minSdkVersion" value="23" />
but does not work. Same error of sdk min versoin 16-19. :roll_eyes:

2 Likes