Gradle error in Android - android

Anyone know what I'm missing? My program worked 5 minutes ago and know I have this strange error:
17:16:38 UnsupportedMethodException
Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.: Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I can't ignore it because I can not run it anymore on my android device, anyone?
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:21.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}

As I thought, there are many out of date plugins/tools here. Please try this fixed and updated build.gradle:
Also, make sure you are using the latest build plugin: com.android.tools.build:gradle:1.1.3.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- was 21
buildToolsVersion "22.0.1" // <-- was 20.0.0
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 22 // <-- was 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:6.5.87' // <-- was 4.2.42
compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.+
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1' // (the only up to date plugin you had)
}

Related

Gradle build fails on android studio 1.2

I am trying to import some libraries, in Android Studio. I had the following error message:
Error:The SDK Build Tools revision (17.0.0) is too low for project ':actionbarsherlock'. Minimum required is 19.1.0
So i installed Android SDK Build tools rev 19.1.0. I modified build.gradle file (app) looking like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.example.xx.xx"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.2"
}
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:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
compile project(':actionbarsherlock')
compile project(':actionbarsherlock-fest')
compile project(':actionbarsherlock-i18n')
}
Also in Run/Debug Configurations, under App Engine DevAppServer, i set in App Engine SDK field the path for the new SDK, looks like that: C:\Users\cami\AppData\Local\Android\sdk\build-tools\19.1.0
So when i am trying to rebuild, i get exactly the same error message as before. Additionally, i had installed Android SDK Build tools rev 22.0.1, and i get warning saying update targetSdkVersion to 22.
Could please someone help me with this?
PS: Sorry for the very long post, and maybe for the many unnecessary details, but i am new in Android Dev.
Thank you
I had similar problem. Please try my code from gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "esub.android.app"
minSdkVersion 17
targetSdkVersion 19
versionCode 5
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Hope it will help.
Do you have installed all required SDK?
Please look at my Android SDK Manager:

Android studio importing in gradle issue

I am new to Android Studio and was just trying to import my eclipse project. i am trying to resolve this issue for quite a while now but unable to.
I have a mainactivity project which uses mmany other libraries staggeredgridview, devsmart, google maps and appcompactv7. I am getting following 2 errors.
Note: mainactivity project is the one which i am working on and uses other external libraries.
Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library B:\Android Studio Projects\mainActivity\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage
:mainActivity:processDebugManifest FAILED
Error:Execution failed for task ':mainActivity:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
build.gradle of mainactivity
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':devsmartAndroid')
compile project(':staggeredGridViewmaster')
compile 'com.google.guava:guava:16.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/commons-codec-1.6.jar')
}
build.grade for devsmart
apply plugin: 'com.android.library'
android {
compileSdkVersion 14
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 4
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
build.gradle for sttageredgridview
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
Just edit minsdk of your build.gradle of mainactivity to 9 :
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 9 // changed line
targetSdkVersion 16
}
Note : Also did the same for other libs if there minsdk is small then 9
Please open your manifest file and write the bellow code it will work
<uses-sdk tools:overrideLibrary="com.google.android.gms"/>
and add the list of libraries for uses-skd separated by comma
Go to all the manifest files or build.gradle files of all the projects and make the minSDKversions the same.8 for instance.

Can't import an eclipse project into android studio?

I am trying to learn android in android studio.Now i imported an eclipse project in android studio and now while trying to run it it is not building.Some problems in gradle may be..
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.practise"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:gridlayout-v7:+'
}
Can anyone help me to find out the problem??
Change your dependencies
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
}
Using the +, you are getting the last release.
Currently the last release is the compile 'com.android.support:support-v4:21 and it has a minSdk='L' because it is a preview release.
Use it only to test the android 'L' preview.
Try editing the following line to your Android Manifest file, like so:
dependencies {
compile 'com.android.support:support-v4:21+'
}
Then your project should build.
Change your dependencies in app/build.gradle to lower version
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.eusecom.snowsmsden"
minSdkVersion 16
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.android.support:appcompat-v7:20.+'
}

Android Studio minSdkVersion not working

The minSdkVersion directive in my build.gradle appears not to be working (Android Studio 0.8.2)
Here's the build.gradle for the "mobile" module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services-wearable:+'
}
When I try to debug it on my Samsung Galaxy S4 (API 19) I see this message in the "Compatible" column:
"No, minSdk(API 20) > deviceSdk(API 19)"
Minimum SDK should clearly be 9 as specified by the build.gradle. If I try to launch it anyway I get:
"Failure [INSTALL_FAILED_OLDER_SDK]"
I've scoured this project for any indication of something that could force the minSdk to 20. Nothing in AndroidManifest.xml. This project is a wearable app.
I've built another wearable app on the same machine and it loads and runs on the Samsung without a problem. This app that I'm trying to use was put together by a friend. It has only a small amount of code. The build.gradles are identical.
Totally baffled. Please help!
Android L version (SDK 20) will be overrides minSdkVersion to 20. You should change your build version to 19 or below version of SDK. for example,
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "example.myapplication"
minSdkVersion 14
targetSdkVersion 19
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:19.+'
}
Modify your build.gradle file like this, and resync your project and rebuild it.
also you should install 19.1 sdk libraries to using SDK Managers. Run android studio as administrator will be help to solve another problems when you install sdk and rebuild your project.
you can change compileSdkVersion 20 to compileSdkVersion 16 to have a try ,it works to me

Android Studio : Failure [INSTALL_FAILED_OLDER_SDK]

Today I have downloaded Android Studio v 0.8.0 beta. I am trying to test my app on SDK 17 . Android studio error Failure [INSTALL_FAILED_OLDER_SDK]
Here is my android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vahe_muradyan.notes" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Main_Activity"
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>
It seems that android studio uses configurations in build.gradle.Here is build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.vahe_muradyan.notes"
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'])
compile 'com.android.support:appcompat-v7:19.+'
}
There are my config to support L and old versions of android:
apply plugin: 'com.android.application'
android {
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.uladzimir_klyshevich.myapplication"
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
l {
minSdkVersion 'android-L'
targetSdkVersion 'android-L'
compileSdkVersion 'android-L'
}
old {
minSdkVersion 10
targetSdkVersion 20
//TODO comment second line if build is not compiles for "L"
compileSdkVersion 20
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
lCompile 'com.android.support:appcompat-v7:21.+'
oldCompile 'com.android.support:appcompat-v7:19.1.0'
}
As result you will have flavors:
oldDebug
oldRelease
lDebug
lRelease
And can install your application on old versions of android.
Do those changes in build.gradle file in the wear module
compileSdkVersion 20
targetSdkVersion 20
So the final wear/build.gradle content will be:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "your package name"
minSdkVersion 20
targetSdkVersion 20
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.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}
I'm using Android Studio Beta version 0.8.1 and I have the same problem. I now I sold my problem by changing the AVD (I'm using Genymotion) to API 19.
and here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.daroath.actionbar"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Hope this help!
I ran into the same issue and solved it by downloading api level 20 using sdk manager and changing every string that points to android-L. I did it because I dont have a kitkat device and don't want to use emulator.
See the image download the marked one.
Here's my build config:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20//changed this from default
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.subash.test"
minSdkVersion 12//changed this from default
targetSdkVersion 20//changed this from default
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
As mentioned before switching to build 19 is the suggested route here until v20 is "fixed". This thread helped me solve the issue, but it seems similar answers have been posted here as well. https://code.google.com/p/android/issues/detail?id=72840
<uses-sdk android:minSdkVersion="19"/>
In AndroidManifest.xml worked for me on Android Studio(Beta)0.8.2.
in the AndroidManifest.xml file change the user-sdk to older version
<uses-sdk android:minSdkVersion="19"/>
Change file AndroidManifest.xml
<uses-sdk android:minSdkVersion="19"/>
<uses-sdk android:minSdkVersion="14"/>
After a lot of research i found the solution for this huge error which i was struggling for 2 days.
Instead of changing the minSdkVerison & targetSdkVersion in build.gradle
Just open the Manifest file and use this
&ltuses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="21"/
Failure [INSTALL_FAILED_OLDER_SDK]
basically means that the installation has failed due to the target location (AVD/Device) having an older SDK version than the targetSdkVersion specified in your app.
FROM
apply plugin: 'com.android.application'
android {
compileSdkVersion 'L' //Avoid String change to 20 without quotes
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.vahe_muradyan.notes"
minSdkVersion 8
targetSdkVersion 'L' //Set your correct Target which is 17 for Android 4.2.2
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:appcompat-v7:19.+' // Avoid Generalization
// can lead to dependencies issues remove +
}
TO
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.vahe_muradyan.notes"
minSdkVersion 8
targetSdkVersion 17
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:appcompat-v7:19.0.0'
}
This is common error from eclipse to now Android Studio 0.8-.8.6
Things to avoid in Android Studio (As for now)
Avoid Strings instead set API level/Number
Avoid generalizing dependencies + be specific
The real issue is that with vanilla Android Studio v 0.8 beta, it only installs/recognize SDK 20 which is android L. In order to target another complieSDK you need to install it via the SDK manager. Once it is set, you can then change the compileSDK to a lower version and it should work.
you may also want to restrict the compatibility library, it needs to be restricted from using the latest version of the library so change the dependecy to something like :
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
I fixed this problem.
I just modified the compileSdk Version 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 initially went into the SDK Manager and updated all that it had set to update.
I also added in the SDK version for the version of Android I had on the Droid I had...Version 2.3.4(10)
I don't think that really fixed anything, and after a Android Studio restart as recommended after the SDK installs, I changed the minSdkVersion to 8 in the build.gradle file
I was then able to download the application to my Droid.
defaultConfig {
applicationId "com.cmcjr.chuck.droid_u"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
This is Android Studio installed on Ubuntu 12.04
Just go to build.gradle(Module:App) and change the minSdkVersion to whatever you are using with emulator.
Example:
defaultConfig {
applicationId "com.example.raghu.sample"
// Change the version in following line
minSdkVersion 10 // <-- Whatever you are using with Emulator
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Just installed Android Studio v 0.8.1 beta and ran into the same problem targeting SDK 19.
Copied 19 from the adt-bundle to android-studio, changed build.gradle to:
compileSdkVersion 19
targetSdkVersion 19
then project -> app -> open module settings (aka project structure): change compile sdk version to 19.
Now works fine.
Similar to a few posts prior - I went to SDK Manager and uninstalled v20 and version L. Then I installed version 19 and this problem was resolved and I could debug using my android device, no errors.
Another way to support Android L is to use custom lpreview property for Gradle. For instance:
lpreview = hasProperty('lpreview')
apply plugin: 'com.android.application'
android {
compileSdkVersion lpreview ? "android-L" : 19
buildToolsVersion "20.0.0"
productFlavors { lpreview ? lpreview{} : classic{} }
defaultConfig lpreview ? {} : {
minSdkVersion 14
targetSdkVersion 19
}
Now, you can build your app with:
./gradlew clean
./gradlew -Plpreview assembleDebug
or
./gradlew -Plpreview installLpreviewDebug
This way you can build your app with lpreview property for Android L and without it for previous versions.
Check the 'minSdkVersion' in your build.gradle
The default project creates it with the latest API, so if you're phone is not yet up-dated (e.g. minSdkVersion 21), which is probably your case.
Make sure the minSdkVersion value matches with the device API version or if the device has a higher one.
Example:
defaultConfig {
applicationId 'xxxxxx'
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
your device older than minSDK , edit minSdkVersion in build.gradle
Try changing you sdk min version
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="19" />
One more place where minSdkVersion makes a sense is a flavor:
productFlavors {
dev {
minSdkVersion 22
}
prod {
minSdkVersion 9
}
}
minSdkVersion (22) will not install on development devices with API level older than 22.
you need update.
This is my current solution (09/2015).
In Android Studio search.
Menu --> Help --> check for update
Upate and problem solved!!
Good luck
Check the minimum API level inside the build.gradle(module: app)[inside of the gradle scripts].
Thatt should be equal to or lower than the device you use
In build.gradle change minSdkVersion 17 or later.

Categories

Resources