I want to change the targetSdkVersion from 19 to 18 in Android Studio (not Eclipse), but failed.
Android Studio complains the following after I changed the targetSdkVersion, and resync the project with Gradle files:
Execution failed for task ':(project name):processDebugManifest'.
> Manifest merging failed. See console for more info.
From the console I found that it is the library I added to the gradle dependencies using the old targetSdkVersion value.
[(Code Directory)\main\AndroidManifest.xml, (Code Directory)\build\exploded-bundles\(Library Directory).aar\AndroidManifest.xml:2] Main manifest has <uses-sdk android:targetSdkVersion='18'> but library uses targetSdkVersion='19'
I learn that in Android Studio, the targetSdkVersion and minSdkVersion flags are defined in the build.gradle file. The project is created with Android Studio's "New project" wizard, and there is NO tag in my code's AndroidManifest.xml. So the problem should not be the two values out of sync. According to the above message, the targetSdkVersion value in the main manifest is what I want.
So the problem should be in the manifest file of the library. I open the library's AndroidManifest.xml file and found the following line:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
Obviously it isn't correct. The problem is that the file is not for manual modification. I tried changing the targetSdkVersion value, and even tried removing the declaration, but it comes back every time I build the project.
I tried cleaning the project, still no luck.
So my question is: Is there a "right" way to alter the targetSdkVersion in Android Studio which I am not aware of?
Here's how to change the targetSdkVersion and minSdkVersion in Android Studio.
Step 1
Open build.gradle - Path\Your_Application\app\build.gradle.
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
Change the targetSdkVersion and minSdkVersion values to what you desire.
Step 2
In the Android Studio menu, find "Build" (Alt + b in Windows) and choose "Clean project".
Alternatively, click on File > Project Structure > Application > Flavours > Min Sdk Version and press ok on change. You can also change the Target Sdk Version as well. I think this is a neater approach to editing the gradle build file directly.
in build.gradle
Change these values according to current project Updation
in sdk manager
compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 15
targetSdkVersion 25
in dependencies replace below code
compile 'com.android.support:appcompat-v7:25.1.0'
and synchronise project
I don't understand this error message
C:\Program Files (x86)\Jenkins\workspace\__temp-mobile-prev\platforms\android\AndroidManifest.xml:67:5 Error:
uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library C:\Program Files (x86)\Jenkins\workspace\__temp-mobile-prev\platforms\android\build\intermediates\exploded-aar\com.paypal.sdk\paypal-android-sdk\2.14.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.paypal.android.sdk.payments" to force usage
Because line 67 of AndroidManifest.xml looks like:
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="22" />
Where does 15 come from?
I use ionic to build my app. But I don't think that this is the problem.
The problem for me was in cordova-plugin-browsertab.
You need to change line 1 of my_project/plugins/cordova-plugin-browsertab/src/android/BrowserTab.gradle to
def minSdkVersion = 19
Make sure you have the minimum SDK added to your config.xml
<preference name="android-minSdkVersion" value="19" />
Then remove and add cordova-android by:
cordova platform remove android
cordova platform add android
In the code editor of your app,
Press Ctrl+Shift+F
Search for minSDKVersion
Replace with the desired version number
Maybe I found the problem.
I don't want to overwride the build.gradle, because cordova create this file dynamically. But I searched why that cdvMinSdkVersion returns a wrong value. And the reason was this barcodescanner-plugin. The plugin gradle file has this line
ext.cdvMinSdkVersion = 15
which overwrite my value from AndroidManifest.xml. After I have remove and add the plugin again it works.
But I don't know why? Maybe someone could explain the order of the different gradle scripts.
As of release 2.14.0, the minSdkVersion has been increased to 16. If you prefer to have your app on a lower minSdkVersion and want to leverage the latest SDK, please disable PayPal for versions below API 16, add xmlns:tools="http://schemas.android.com/tools inside the manifest's xml declaration, and add the following snippet to your AndroidManifest.xml:
<uses-sdk android:minSdkVersion="INSERT_YOUR_DESIRED_minSdkVersion_HERE" tools:overrideLibrary="com.paypal.android.sdk.payments"/>
The easier way to do this is to:
-Go to Build.gradle(Module:app).
-Change minSDKVersion 15 to minSDKVersion 16.
-Sync your project.
Here are some context to understand the things:
By default, when importing a library with a minSdkVersion value that's higher than the main manifest file, an error occurs and the library cannot be imported. To make the merger tool ignore this conflict and import the library while keeping your app's lower minSdkVersion value, add the overrideLibrary attribute to the tag. The attribute value can be one or more library package names (comma-separated), indicating the libraries that can override the main manifest's minSdkVersion.
For example, if your app's main manifest applies overrideLibrary like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:targetSdkVersion="22" android:minSdkVersion="2"
tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
Then the following manifest can be merged without an error regarding the <uses-sdk> tag, and the merged manifest keeps minSdkVersion="2" from the app manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lib1">
<uses-sdk android:minSdkVersion="4" />
In case of Hybrid/Ionic app such issue could get fixed by changing minSdkVersion in config.xml is what I did.
work like a charm:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aspireone.myapplication"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:targetSdkVersion="28" android:minSdkVersion="14"
tools:overrideLibrary="com.allyants.draggabletreeview"/>
from this error message:
<!-- Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library [com.github.jakebonk:DraggableTreeView:1.0.1] C:\Users\ASPIREone\.gradle\caches\transforms-1\files-1.1\DraggableTreeView-1.0.1.aar\45f4095d2e68f3e9a1fbc4b73c7f9c33\AndroidManifest.xml as the library might be using APIs not available in 14
Suggestion: use a compatible library with a minSdk of at most 14,
or increase this project's minSdk version to at least 15,
or use tools:overrideLibrary="com.allyants.draggabletreeview" to force usage (may lead to runtime failures) -->
The problem started for me after I added "jitPak" library for viewing PDF, the root cause of the problem turn out to be line 13 in build.gradel (Module Level). Just change the version from 15 to 16, will resolve the issue.
android { // line 7 of build.gradle (module App)
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.web_app"
minSdkVersion 15 // change this to 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
This solved my problem.
Right click on app folder in android studio, select 'open module settings' | or just press F4. Go to Flavors Tab and change Min Sdk Version to the latest.
Problem Solved.
Increase the minSdkVersion as your requirement, hope it will be solved.
I will prove to you that The easier way to do this is to apply these 3 steps following:
1) Go to Build.gradle(Module:app).
2) Change minSDKVersion 15 to minSDKVersion 16. or 17
// 19(for projectfolder/platforms/android/CordovaLib/AndroidManifest.xml)
3) Sync your project.
I had the same issue when working on an android application using Flutter:
Flutter Suggestion:
Solution:
I use #Naga suggestion, and it's work.
config.xml that I change is not in the root of project, but in
platforms/android/app/src/main/res/xml/config.xml
and minSdkVersion in AndroidManifests.xml are not overwritten again
Try this instead.
Change minSdkVersion 15 to minSdkVersion 16 in build.gradle(module: app)
This error message means that the minimal android version of the paypal library is 16, not your own app's version.
If one of the 3rd party libraries you use has the bigger minimum version than your version, you have to increase your minSdkVersion to them.
Go to build.grade and inside the defaultConfig there is minSdkversion and change that to 17 and sync now and it work i mean it at least worked for me
Downgrade your version 'audioplayers: ^0.17.1' to 'audioplayers: ^0.16.1' in pubspec.yaml and pub get the dependencies of 'audioplayers: ^0.16.1'.
I have the same problem. And I solve it changing in C:\Users\"Username"\.gradle\gradle.properties cdvMinSdkVersion to 19
org.gradle.daemon=false
org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=false
android.enableJetifier=false
cdvMinSdkVersion=19
I found out when I Import the project in Android Studio.
Set the minSdkVersion in android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 20
}
}
The way I fixed it was to go to platforms\android folder and did a find-in-folder from my VS code editor for minSdkVersion and replaced all minSdkVersion=16 to minSdkVersion=19 regardless of whether cordova generated it dynamically or not. Everything worked fine for me after that.
go to the folder /platforms/android/android.json
change the minsdk version to whatever you want
{
"xml": "<preference name=\"android-minSdkVersion\" value=\"22\" />",
"count": 1
},
then go to the plugin that may have messed you up /plugins/{yourplugin}/plugin.xml
change the preference value too to the number you want
<preference name="android-minSdkVersion" value="22" />
then check your /platforms/android/build.gradle file and confirm the same value
project.ext {
defaultBuildToolsVersion="29.0.2" //String
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}
Please Follow these three steps to solve this error in ionic 3
In projectfolder/platforms/android/CordovaLib/AndroidManifest.xml change
<uses-sdk android:minSdkVersion="16" />
to
<uses-sdk android:minSdkVersion="19" />
in projectfolder/platforms/android/gradle.properties change
cdvMinSdkVersion=16 or X
to
cdvMinSdkVersion=19
in projectfolder/config.xml
change
<preference name="android-minSdkVersion" value="16" />
to
<preference name="android-minSdkVersion" value="19" />
I think try to delete implementation 'com.google.firebase:firebase-analytics' in folder android/App/build.gradle. before doing the long steps above
The error shown means that the package that you are using doesn't support minSdkVersion 15. so try to change in your "Project/android/app/build.gradle" the following :
minSdkVersion from 15 to 16 or higher
change this code to -->>>>
minSdkVersion flutter.minSdkVersion ->>>
minSdkVersion 19
I got same problem today when I added firestore dependency in flutter. It was solved by doing mentioned changes in the android/app/build.gradle file
Before
defaultConfig {
minSdkVersion flutter.minSDKVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
After
defaultConfig {
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
N.B : doing minSDKVersion 19 won't work change it to minSDKVersion 21.
In case if above changes does not work you can follow steps mentioned in following website.
https://ao-system.net/en/note/224
I'm a newbie who installed Android studio but simply can't get a simple hello world app to run!
Whenever I try running a program, I get the error :
Failure [INSTALL_FAILED_OLDER_SDK]
I've been googling but to no avail. I've changed build.gradle to :
defaultConfig {
applicationId "com.minimap.Minimap.minimap"
minSdkVersion 8
targetSdkVersion 8
versionCode 1
versionName "1.0"
}
and I added this to my manifest :
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
Yet the hello world app fails to run on two different cellphones (a samsung galaxy s3, and an alcatel), so I'm guessing the problem is on android studio's side. I'd like to mention that I have not forgotten to install the API 8 sdk
Do you guys have any idea what might be going on? Any help would be greatly appreciated.
You should try to set your targetSDKVersion to 22 (The lastest Android revision).
It will let you use the latest library included in Android.
Also, on Android studio, using Gradle, you dont' have to add the uses-sdk tag in your Android Manifest
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
It will be override during the build phase
I want to change the targetSdkVersion from 19 to 18 in Android Studio (not Eclipse), but failed.
Android Studio complains the following after I changed the targetSdkVersion, and resync the project with Gradle files:
Execution failed for task ':(project name):processDebugManifest'.
> Manifest merging failed. See console for more info.
From the console I found that it is the library I added to the gradle dependencies using the old targetSdkVersion value.
[(Code Directory)\main\AndroidManifest.xml, (Code Directory)\build\exploded-bundles\(Library Directory).aar\AndroidManifest.xml:2] Main manifest has <uses-sdk android:targetSdkVersion='18'> but library uses targetSdkVersion='19'
I learn that in Android Studio, the targetSdkVersion and minSdkVersion flags are defined in the build.gradle file. The project is created with Android Studio's "New project" wizard, and there is NO tag in my code's AndroidManifest.xml. So the problem should not be the two values out of sync. According to the above message, the targetSdkVersion value in the main manifest is what I want.
So the problem should be in the manifest file of the library. I open the library's AndroidManifest.xml file and found the following line:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
Obviously it isn't correct. The problem is that the file is not for manual modification. I tried changing the targetSdkVersion value, and even tried removing the declaration, but it comes back every time I build the project.
I tried cleaning the project, still no luck.
So my question is: Is there a "right" way to alter the targetSdkVersion in Android Studio which I am not aware of?
Here's how to change the targetSdkVersion and minSdkVersion in Android Studio.
Step 1
Open build.gradle - Path\Your_Application\app\build.gradle.
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
Change the targetSdkVersion and minSdkVersion values to what you desire.
Step 2
In the Android Studio menu, find "Build" (Alt + b in Windows) and choose "Clean project".
Alternatively, click on File > Project Structure > Application > Flavours > Min Sdk Version and press ok on change. You can also change the Target Sdk Version as well. I think this is a neater approach to editing the gradle build file directly.
in build.gradle
Change these values according to current project Updation
in sdk manager
compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 15
targetSdkVersion 25
in dependencies replace below code
compile 'com.android.support:appcompat-v7:25.1.0'
and synchronise project
I'm using the latest and greatest IntelliJ Community edition. My application runs fine on the android emulator. However, I need the emulator to better match the Kindle Fire. I made the configuration changes in the AVD Manager (including setting device to API 10.)
When I went to my project to configure the project to target the new virtual device, I got the following message: "Build target of AVD DEV3 is not compatible with your build target."
It didn't take much work to figure out that the issue is related to my choice of API 10.
I don't know where I tell my project to use API 10. I looked all over and didn't see any references to the API level at all. Any ideas?
EDIT
I added
<uses-sdk android:minSdkVersion="10" />
to my AndroidManifest.xml file and was able to select the new device. I'm starting it up now.
The answer above is no longer true in Intellij (using gradle)
Now <uses-sdk> is ignored in the AndroidManifest.xml, it is automatically added to the built manifest file. To change the version, go to the 'build.gradle' file and look at the minSdkVersion.
As Tony and Blundell mention, the answer is to declare your minSdkVersion in your AndroidManifest.xml file. In this way, the application will be allowed to launch on any AVDs that at least meet the minSdkVersion.
Here's more documentation on the <uses-sdk> tag:
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
Set this value in the Gradle file - as shown here:
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.kotlinconverterapp"
**minSdkVersion 26**
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}