构建空PhoneGap项目遇minSdkVersion错误:版本14低于CordovaLib要求的16
Hey Arjun, that error is a super common hiccup with newer Cordova/PhoneGap versions—let’s break it down and fix it right away:
The Root of the Problem
Your project is configured to use minSdkVersion 14, but the core CordovaLib library that PhoneGap relies on now requires a minimum Android SDK version of 16. That mismatch is what’s throwing the build error.
Here’s your original error for reference:
Error: /home/arjun/Desktop/phone/goodbackup/platforms/android/gradlew: Command failed with exit code 1 Error output: /home/arjun/Desktop/phone/goodbackup/platforms/android/app/src/main/AndroidManifest.xml:16:5-74 Error: uses-sdk:minSdkVersion 14 cannot be smaller than version 16 declared in library [:CordovaLib] /home/arjun/Desktop/phone/goodbackup/platforms/android/CordovaLib/build/interm...
Step-by-Step Solutions
1. Quick Temporary Fix
Head to platforms/android/app/src/main/AndroidManifest.xml in your project, find this line:
<uses-sdk android:minSdkVersion="14" ... />
Change the 14 to 16, save the file, and retry your build. Note: This change might get overwritten if you run cordova prepare android later, so use the next method for a permanent fix.
2. Permanent Recommended Fix
Open your project’s root config.xml file, add or update this preference:
<preference name="android-minSdkVersion" value="16" />
Save the file, then run this command to apply the setting to your Android platform:
cordova prepare android
Now your project will default to minSdkVersion 16, and the conflict won’t pop up again.
3. Bonus: Update Cordova (Optional)
If you’re using an older Cordova version, updating to the latest stable release can prevent similar compatibility issues down the line. Run this in your terminal:
npm update -g cordova
That should get your empty PhoneGap project building smoothly!
内容的提问来源于stack exchange,提问作者arjun

