Android Studio gradle build successfully despite api level error - android

I am working on an android project that Api level is 10, its is declared in build.gradle and AndroidManifest.xml files
defaultConfig {
minSdkVersion 10
targetSdkVersion 15
}
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
When I use ActionBar class Android Studio Editor underlined this line and gave warning as I expected "Call requires API level 11(current min is 10):android.app.ActionBar..."
but when I compile project , it is compiled successfully. It can be cause errors , how can it be worked on API lvl 10 devices.I want an error about this, but it compiled.How can I get a build error about this. ty.

What you are seeing is the Android lint tool displaying errors, but Android Studio still allowing compilation.
This is because the lint errors you see do not prevent compilation. It seems that Android Studio (at least in v1.3.2) the build process ignores lint errors during compilation by default, whereas in Eclipse w/ ADT plugin you would not be able to compile.
Looking at Improving with Lint, you can modify your build.gradle file with lint options in order to have the build fail:
android {
lintOptions {
// if true, stop the gradle build if errors are found
abortOnError false
}
}

Change below...
defaultConfig {
minSdkVersion 11
targetSdkVersion 15
}
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
After setting gradle or menifest. clean and rebuild your project. hope it will work.... if still not working restart tool and try to compile project again....

Related

ERROR: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 19 declared in library [__tested_artifact__::CordovaLib]

I'm creating a cordova android project first time.upto build project everythings goes okey.after building the project, when I try to open in the Android IDE, Android Studio,
I'm getting this error.
ERROR: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be
smaller than version 19 declared in library
[tested_artifact::CordovaLib]
E:\projects\cordova\hello1\platforms\android\CordovaLib\build\intermediates\library_manifest\debug\AndroidManifest.xml
as the library might be using APIs not available in 1 Suggestion: use
a compatible library with a minSdk of at most 1, or increase this
project's minSdk version to at least 19, or use
tools:overrideLibrary="org.apache.cordova" to force usage (may lead to
runtime failures)
here is setup information
I tried adding
preference name="android-minSdkVersion" value="19"
In Config.xml (Project directory).
It didn't work.
Please help me fixing this.
Thanks,
Deleting
<uses-sdk android:minSdkVersion="19" />
inside android/CordovaLib/AndroidManifest.xml helped to resolve the issue
I had same issue when building my app with Ionic. I solved it by making changes to gradle.properties(Project Properties) file. Change the cdvMinSdkVersion to the min targeted version which in my case was 22 then click on sync project. After build or run the project.
cdvMinSdkVersion=22
I had same issue when building my app with Ionic. I solved it by making changes to gradle.properties(Project Properties) file. Change the cdvMinSdkVersion to the min targeted version which in my case was 22 then click on sync project. After build or run the project.
cdvMinSdkVersion=22
This worked for me too.
I have not worked on Cordova, But works on Android apps development. The issue you described is because you are using library that has minSdkVersion 19. And you cannot use lower then that in your project. Change minSdkVersion in /platforms/android/app/build.gradle file.
As you need to change apps minSdkVersion.
Change the cdvMinSdkVersion in gradle.properties

Manifest merger failed error during build

I'm trying to build an app for API 7 which is the device I need to run it on.
I've set the minSDK to 7, and added the following:
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19"
tools:ignore="OldTargetApi"
tools:overrideLibrary="android.support.test.espresso,
android.support.v7.appcompat,
android.support.v4,
android.support.mediacompat,
android.support.fragment,
android.support.coreui,
android.support.coreutils,
android.support.graphics.drawable,
android.support.compat">
</uses-sdk>
However, during the (gradle) build I get the following error:
Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 7 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] C:\Users\david\.android\build-cache\828bf92787e99464e08501328373b997b66ab556\output\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage
Everything worked fine until I set the min sdk to 7 (it was 26).
What else do I have to do to get this to build? Thanks
If your android:minSdkVersion="7" is a mandatory, you can try using the old version of espresso in your app build.gradle with the following dependencies:
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
You can found the version list in Testing Library Support Release Notes
uses-sdk:minSdkVersion 7 cannot be smaller than version 8 declared in
library
Your error is perfectly clear.Some of your included libraries configured to use with Minimum of SDK version 8.
Please downgrade the libraries to 7 or upgrade your App to 8.
Ok, this issue is resolved. As advised, I removed the reference to espresso, and found a solution to Dex problem on SO. Thanks to all who replied.

Stop working project with vector drawables after update build.gradle on API < 21

I have working project.
minSdkVersion 17
com.android.tools.build:gradle:2.3.3
gradle 4.1
Android Studio 3 Canary 6
I have in my gradle files:
defaultConfig {
vectorDrawables.useSupportLibrary = true
vectorDrawables.generatedDensities = []
}
I call in activity too:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
Application works perfectly. Now change to:
com.android.tools.build:gradle:3.0.0-alpha6
add to repositories google() line
Execute gradle clean assembleDebug.
App continue works on devices with API > 20. But for API < 21 (google android emulator) get crash on start application.
I see in logcat error: Resources$NotFoundException: Resource ID #0x7f080058 (0x7f080058 is drawable abc_vector_test).
Why?
UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7
I'm add to gradle.properties line
android.enableAapt2=false
and it's solve my error.
UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7
Gradle plugin from version 3 use new AAPT, that have some bugs.
After reading some issues on bug tracker, I've found that Gradle has option for full disable AAPT2: android.enableAapt2=false
Also from release notes to alpha5:
AAPT2. We are continuing to stabilize AAPT2 which enables incremental resource processing. If your build fails due to resource
processing issue, please send us a bug report. To temporarily disable
AAPT, set android.enableAapt2=false in your gradle.properties file.
Roboelectric is currently not compatible with AAPT2
I am facing the same problem, downgrade Android Studio to previous version canary5 and write the following in your build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
...

uses-sdk element cannot have a "tools:node" attribute

I've updated Android Studio last night to 0.9.0, buildToolsVersion to 21.1.0 and gradle to 0.14.0, after that I'm receiving this error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute
I've spent the last night looking for a solution, I found this:
<uses-sdk tools:node="replace" />
But unfortunately, added one more error!
Error:(10, 5) uses-sdk element cannot have a "tools:node" attribute
Error:(10, 5) Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute
Another solution I've read, to not use support-v4:21, for me I don't use it, since I'm using v13.
Solution:--
Add this line to uses-sdk tag like this:-
<uses-sdk
tools:node="merge" <----This line do the magic
android:minSdkVersion="14"
android:targetSdkVersion="19" />
And add the tools name space in manifest :-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" .....
.../>
OK this is not the answer, but a temporary workaround.
According to the Gradle build tools release notes this problem was fixed in version 0.13.2 (2014/09/26)
However, seems to happen again in 0.14.0 (2014/10/31)
You can disable the manifest merger task in order to build your project for the time being.
Add the following in your build.gradle file
android.applicationVariants.all { variant ->
variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
variant.processManifest.enabled=false }
See this question for reference.
I ran into this after upgrading to Android Studio 1.0.0 rc4. I had previously been using so that I could make projects with lower min SDK versions than some of the libraries they depended on. Turns out, if you remove tools:replace and let the compiler error out again with the manifest merge conflict, it will provide you with a much better solution:
<uses-sdk tools:overrideLibrary="com.google.android.gms" />
At least, the Google Play Services library was what I was running into. Actually, you can list a whole bunch if you need to. Just comma-separate the package names. You may have to run the compiler a few times until it tells you every library that's causing problems.
My solution
I have removed all of the <uses-sdk tools:node="replace" /> From all of my manifest.xml files
In my base.gradle file(the one for the entire project I Added
ext {
compileSdkVersion = 19
buildToolsVersion = "21"
minSdkVersion = 10
targetSdkVersion = 19
}
In my modules I have this
// all modules
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
// in an application module
defaultConfig {
applicationId "com.something"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode appVersionCode
versionName appVersionName
}
The problem has solved after updating the AS to v0.9.1 and Gradle to 0.14.1.
Thank you guys_
Update
The problem appears again!
Update 2
Here is a workaround to solve this problem:
Open your project with Android Studio 0.8.14 / Gradle build tools 0.13.2
Build your project.
Switch back to Android Studio 0.9.1 / Gradle build tools 0.14.1
gradlew assembleRelease will work now

How to change the Android Studio Project minSDK version?

I had a recurring error that I wasnt sure how to correct. My android studio was returning the an error indicating that my minSdk version was 11 and had to 14 in order to use the NoTitleBar parent reference in styles.xml. My AndroidManifest had the tag <uses-sdk android:minSdkVersion="14"/> but the error would not go away. I re-cleaned the project and tried to build again - same error.
Android Studio version: 0.8.6
OS: Win8.1
In app > build.gradle file try to modify this section
defaultConfig {
minSdkVersion 11
}
Best regards
Although I had the minSdk set in the manifest the project level sdk was overriding this or at least causing a collision. I located this way: File -> Project Structure -> App -> Flavors -> Change the minSdk version to whatever you need (preferably to match whats in the manifest if its declared - otherwise remove it from there). Hope this helps.
As a note I also next ran into this error I have not resolved yet:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1

Categories

Resources