I am using the latest Android Studio 1.2.2. While trying to set AppTheme to Theme.Material according to this answer to support for older versions too(other than API 21) and many other solutions on the internet I did everything that was written. I made a different values folder named values-v21 and styles.xml in that folder. Then I wrote <uses-sdk tools:node="replace" /> , the build gave me an error saying:
Error:(6, 5) uses-sdk element cannot have a "tools:node" attribute
Error:(6, 5) Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute.
Here is my app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.amangrover.finalapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
I thought this problem was fixed for newer versions of Android Studio?
Add this lines in your project's AndroidManifest.xml file to uses-sdk tag like this:-
<uses-sdk
tools:node="merge"
android:minSdkVersion="14"
android:targetSdkVersion="19"/>
And also add the tools name space in manifest :-
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" .....
.../>
Related
I migrated an older Android app to Android-Studio/Gradle. The test need uiautomator-v18 which requires minSdkVersion=18. However, I would like to have the minSdkVersion set to 15 or 16.
There are many questions on SO over the same thing, but I am just not able to resolve this problem.
Exerpt AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.searcher"
android:versionCode="1"
android:versionName="0.0.1" >
<uses-sdk
tools:overrideLibrary="android.support.test.uiautomator.v18"/>
<!-- ... -->
</manifest>
The build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.searcher"
minSdkVersion 15
targetSdkVersion 23
testApplicationId "com.example.searcher.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile files('libs/dagger-1.2.1.jar')
compile files('libs/dagger-compiler-1.2.1.jar')
compile files('libs/javawriter-2.1.2.jar')
compile files('libs/javax.inject.jar')
androidTestCompile(
'com.android.support:support-annotations:23.2.0',
'com.android.support.test:runner:0.4.1',
'com.android.support.test:rules:0.4.1',
'com.android.support.test.uiautomator:uiautomator-v18:2.1.1',
'org.hamcrest:hamcrest-library:1.3',
'org.mockito:mockito-core:1.10.5',
'junit:junit:4.12',
'com.google.dexmaker:dexmaker:1.1',
'com.google.dexmaker:dexmaker-mockito:1.1'
)
}
The above gives the error:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 18 declared in library [com.android.support.test.uiautomator:uiautomator-v18:2.1.1] /mypath/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.uiautomator.v18" to force usage
But I am already using the overrideLibrary.
If this is not possible, is it possible to have different minSdkVersion for "main" and "androidTest"?
EDIT:
After adding the flavors, I was able to run the tests using build variant tstDebug. However, building it with prdDebug ends in an error saying that there are unknown stuff in the androidTest (example: package org.hamcrest does not exist). The modified excerpt of build.gradle:
defaultConfig {
applicationId "com.example.searcher"
targetSdkVersion 23
versionCode 6
versionName "0.5.0"
}
productFlavors {
prd {
minSdkVersion 15
}
tst {
minSdkVersion 18
testApplicationId "com.example.searcher.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}
// And instead of "androidTestCompile" use "tstCompile"
Is it not possible to tell "Android Studio" that it should build the app without androidTest?
Did you put <uses-sdk tools:overrideLibrary ...> in src/main/AndroidManifest.xml?
If so, remove it from src/main/AndroidManifest.xml and try to put the following xml in src/androidTest/AndroidManifest.xml.
(Don't forget android:minSdkVersion="18")
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="YOUR PACKAGE NAME"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk
android:minSdkVersion="18"
tools:overrideLibrary="android.support.test.uiautomator.v18"
/>
</manifest>
One option is to have a product flavor for your tests:
android {
productFlavors {
production {
minSdkVersion 15
}
uiTest {
minSdkVersion 18
}
}
...
}
And then run the tests on the uiTest flavor builds.
I am trying to add a dependency in my app which has the minimum sdk version newer than my apps so I am getting the following error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library
Suggestion: use tools:overrideLibrary="com.nononsenseapps.filepicker" to force usage
but I don't know where to add that suggestion so I can build it.
This is how my build.gradle(Module: app) looks right now
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.codedspycamera.android"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.nononsenseapps:filepicker:+'
compile 'com.squareup.picasso:picasso:2.4.0'
}
com.nononsenseapps.filepicker works only on >=14 version android device. I think it will crash if you force it to work on <14 devices. But anyway if you want to do this, you should force using minSdkVersion params from your main app to override library value. Add suggested line to main app manifest. Read this for more information.
Just to make the answer more clear for everyone this is what you have to do
tools:overrideLibrary marker
A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version.
Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.
Example, In the main android manifest :
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
will allow the library with the following manifest to be imported without error :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lib1">
<uses-sdk android:minSdkVersion="4" />
</manifest>
Note that the if multiple libraries are added than they must be separated with a comma ","
For ionic developers
config.xml - add -
<preference name="android-minSdkVersion" value="19" />
bundle.gradle - add
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
I'm new to Android and I'm using the Android Studio. I've created a new project just to show the Hello World! but I can't get it working on the AVD because of this error: Failure [INSTALL_FAILED_OLDER_SDK].
I already searched for the answer and I know it's something about the build.gradle and the minSdkVersion but any of the answers worked for me.
This is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.scoelli.test" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And this is my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.scoelli.test"
minSdkVersion 8
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I would appreciate not only the answer but the explanation.
Thank You!
Unless you know you want to be using the Android L developer preview with your application, do not target and compile with it. It is still very much a preview release, and it appears as though applications targeting and compiling for the preview cause this error with any non-L device.
Update these lines in your build.gradle to stick with the latest stable release (Android 4.4, API 19):
android {
compileSdkVersion 19
defaultConfig {
targetSdkVersion 19
}
}
I fixed this problem.
I just modified the compileSdkVersion from android_L to 19
to target my nexus 4.4.4.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
**compileSdkVersion 'android-L'** modified to 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.antwei.uiframework.ui"
minSdkVersion 14
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
**compile 'com.android.support:support-v4:21.+'** modified to compile 'com.android.support:support-v4:20.0.0'
}
how to modified the value by ide.
select file->Project Structure -> Facets -> android-gradle and then modified the compile Sdk Version from android_L to 19
sorry I don't have enough reputation to add pictures
I think projects with
compileSdkVersion 'android-L'
cannot be installed in other Android versions right now.
I might be wrong there but if you're not doing anything specific to the L preview SDK, just set the compile version to one of the official ones.
Same goes for the targetSdk.
You can choose those in the Create Project wizard.
If you get this error when compiling Adobe AIR mobile app - just correct "minSdkVersion" this line in the application descriptor xml file:
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="15"></uses-sdk>
I'm new to Android and I'm using the Android Studio. I've created a new project just to show the Hello World! but I can't get it working on the AVD because of this error: Failure [INSTALL_FAILED_OLDER_SDK].
I already searched for the answer and I know it's something about the build.gradle and the minSdkVersion but any of the answers worked for me.
This is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.scoelli.test" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And this is my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.scoelli.test"
minSdkVersion 8
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I would appreciate not only the answer but the explanation.
Thank You!
Unless you know you want to be using the Android L developer preview with your application, do not target and compile with it. It is still very much a preview release, and it appears as though applications targeting and compiling for the preview cause this error with any non-L device.
Update these lines in your build.gradle to stick with the latest stable release (Android 4.4, API 19):
android {
compileSdkVersion 19
defaultConfig {
targetSdkVersion 19
}
}
I fixed this problem.
I just modified the compileSdkVersion from android_L to 19
to target my nexus 4.4.4.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
**compileSdkVersion 'android-L'** modified to 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.antwei.uiframework.ui"
minSdkVersion 14
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
**compile 'com.android.support:support-v4:21.+'** modified to compile 'com.android.support:support-v4:20.0.0'
}
how to modified the value by ide.
select file->Project Structure -> Facets -> android-gradle and then modified the compile Sdk Version from android_L to 19
sorry I don't have enough reputation to add pictures
I think projects with
compileSdkVersion 'android-L'
cannot be installed in other Android versions right now.
I might be wrong there but if you're not doing anything specific to the L preview SDK, just set the compile version to one of the official ones.
Same goes for the targetSdk.
You can choose those in the Create Project wizard.
If you get this error when compiling Adobe AIR mobile app - just correct "minSdkVersion" this line in the application descriptor xml file:
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="15"></uses-sdk>
I am not sure what's the issue. I googled and though it was about matching the sdk versions. They are the same as follows:
build.gradle
android {
compileSdkVersion 17
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 4
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':slidingMenu')
compile project(':slidingMenu')
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
compile files('libs/Parse-1.4.0.jar')
}
Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gurbani.ujagar"
android:hardwareAccelerated="true"
android:installLocation="preferExternal"
android:versionCode="26"
android:versionName="7.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
You will be ended up with this error, If your libraries/modules uses different minSdkVersion or targetSdkVersion inside your project.
To find , In which module actual conflicts are happening you can see your Gradle Console output.
Best practice is to have minSdkVersion 8 at least because most of the libraries like play services etc using this.
Please do the following change and sync Project with gradle
Try to Use minsdkVesion 8 in all your build.gradle files as well as AndroidManifest.xml files ans sync.
If it doesn't solves the problem go through your gradle console to and make required changes as per the error shown.
Note : While compilation, your minSdkVersion and targetSdkVersion in AndroidManifest.xml will be overridden by what you have mention in your build.gradle files.
I think slidingMenu library minSdkVersion is greater than yours (minSdkVersion 4). So manifests cant be merged. You cant use library that requires min version 11 (e.g.) in app that works on api version 4.