Gradle code not building: aidl is missing - android

I updated android studio from version 1.0 to 1.2.1 and when I started my first application the this appears.
Error:Execution failed for task ':app:compileDebugAidl'.
aidl is missing
I have made sure that all sdk are up to date. This is my gradle build code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
defaultConfig {
applicationId "com.example.william.myapplication"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
compileSdkVersion 21
}
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'
}

It seems that AndroidStudio-1.3-Preview is using an unexpected version of the gradle plugin. (at least when you create a fresh new project)
Similarly, if you open an existing project using:
an older version of the plugin. (<1.3.0-beta1)
latest build tools (23.0.0-rc1)
compileSDK 22
---> you will probably have this strange error : "aidl is missing" (even in projects not using aidl !)
Solution:
Be sure to use the latest android-gradle-plugin (in the root build.gradle) :
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
under buildscript-->dependencies.
Example :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and the latest build tools (in module build.gradle):
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
... }
BE AWARE that with this config you are using the latest build tools -not released yet- and the preview of Android-M ---> things can be unstable

I had the same error. I changed the build tools version in the gradle script to my actual sdk build tool version found in sdk manager and that did the trick.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
...

Related

Error on Android app Azure dependency gradle build

I am getting the following error on Android Studio 2.3.3 at Gradle sync.:
"`Error:Module 'com.microsoft.azure:azure-mobile-android:3.3.0' depends on one or more Android Libraries but is a jar."
The error disappears if I use
compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
instead of
compile 'com.microsoft.azure:azure-mobile-android:3.3.0'
but i don't want to use an outdated version.
build.gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.my_software.myapp"
minSdkVersion 14
targetSdkVersion 25
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-drive:11.0.1'
compile 'com.google.android.gms:play-services-plus:11.0.1'
//FOR microsoft Azure
compile 'com.microsoft.azure:azure-mobile-android:3.3.0'
}
TEMPORARY SOLUTION:
compile('com.microsoft.azure:azure-mobile-android:3.3.0#aar'‌​)
(add #aar at the end).
I reviewed the source code of azure-mobile-apps-android-client on GitHub, and the difference of the build.gradle between 3.1.0 and 3.3.0 is that the version 3.3.0 required the dependency com.android.support:customtabs:23.0.1, but version 3.1.0 not. So you need to downgrade the compileSdkVersion & targetSdkVersion value from 25 to 23 to support the required Android library to resolve it, due to com.android.support:customtabs:23.0.1 is belong to Android API 23.

Gradle failed to sync with 'unable to find optional library'

I had to reinstall my system and today I get this error in Android Studio when I try to sync with gradle:
Warning: Unable to find optional library: org.apache.http.legacy
My project gradle is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
And my module gradle:
apply plugin: 'android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
}
From the google docs:
To continue using the Apache HTTP APIs, you must first declare the
following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
I tried the suggestions mention in this thread but they don't work. Same result with android studio 1.5 and 2 preview.
How can I fix this?
Edit: Things I've tried so far:
Change gradle classpath versions to 1.3.0, 1.3.1, 1.5.0.
Change the compileSdkVersion and targetSdkVersion to 22. Also the buildToolsVersion from 23.0.1, 23.0.0, 22.0.1.
Top level build.gradle - /build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
Module specific build.gradle - /app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}
Add org.apache.http.legacy.jar which is in Android/Sdk/platforms/android-23/optional folder to app/libs directory and sync your project
After a lot of working this solutions work for me
.
** Studio\Android\sdk\platforms** here delete your android-23 and from sdk manager update api 23 again.**
.
it will solve your issue.
In my case, it didn't work because I was missing optional.json in <sdk-path>\platforms\android-23\optional\, directory with the following content:
[
{
"name": "org.apache.http.legacy",
"jar": "org.apache.http.legacy.jar",
"manifest": false
}
]
Creating a new JSON file with with above content solved the problem for me.
You need to add org.apache.http.legacy.jar jar file in your Android Stuido project's app/libs folder.
Jar Location - `<SDK LOCATION>\android-sdk\platforms\android-23\optional`
To do this, just right click on your project and select Show in Explorer then go to ...\app\libs and paste above jar file and Sync your Project with Gradle File
Module:app
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "<ur_app_id>"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Update your project gradle file to use gradle version 1.3.1.
classpath 'com.android.tools.build:gradle:1.3.1'
Also try adding codehause repo.
repositories {
mavenCentral()
maven{
url 'http://repository.codehaus.org'
}
}
In my case the problem was actually occurring because I didn't have the correct SDK installed on that computer. Navigating to .../Android/Sdk/platforms/android-23 I could see that folder was empty. Adding SDK 23 via the SDK manager fixed the problem and allowed me to compile.
You should manually check that you have the same version of the SDK installed that is specified under compileSdkVersion in your build.gradle file.
To save time 2 solutions are best and works for me.
Solution 1 :
open your android sdk manager and reinstall API 23 (remove and install again).
Solution 2 :
Download this file which contain optional.json file
extract and move optional.json to :
C:\Users\\AppData\Local\Android\sdk\platforms\android-23\optional
if above solution is not work then try this way
I experienced this problem recently, and it is caused by the path length restriction I think it´s 256 characters maximum.
Relocate your Project and the build will succeed.
Copy "sdk\platforms\android-23\optional\org.apache.http.legacy.jar" to your app module libs directory, then add as library;
If you enable the proguard, please edit "proguard-rules.pro" to keep related classes or exception will occurred.

Questions about Data Binding in Android Studio

I heard of something about Data Binding early today. Since I wanted to have a try of it and know about it, I created a test project.
Data Binding is is a support repository available on API 7+. with dataBinder, we are capable of saying goodbye to findViewById (which is complained about a lot by developers) when binding application logics and layouts.
Here are information about my project:
Android Studio:
Current version: Android Studio 1.3
Build number: AI-141.2071668
Android SDK Tools: 24.3.3
Android Platform Version: MNC revision 2
Project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta4'
classpath 'com.android.databinding:dataBinder:1.0-rc0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "me.danielpan.databindingsample"
minSdkVersion 9
targetSdkVersion 'MNC'
versionCode 1
versionName '1.0.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
}
And when I run this project on a Genymotion Emulator(which is Nexus 5 in Android 5.1.0), errors happened:
Installing me.danielpan.databindingsample
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/me.danielpan.databindingsample"
pkg: /data/local/tmp/me.danielpan.databindingsample
Failure [INSTALL_FAILED_OLDER_SDK]
DEVICE SHELL COMMAND: pm uninstall me.danielpan.databindingsample
DELETE_FAILED_INTERNAL_ERROR
So, I have some questions:
1, DELETE_FAILED_INTERNAL_ERROR happened many times. It seems that this error happens when I set
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
So, it's the problem of Android Build Tools of this version?
2, I followed Data Binding Guide, but I think it's old. Because Gradle Plugin has been 1.3.0-beta4, version of dataBinder should have evolved since released. So, what's is the latest version of Data Binding Plugin?
Any tips will be appreciated. Thanks in advance.
P.S.:
When I set version of Gradle Plugin 1.2.3, buildToolsVersion "22.0.1" compileSdkVersion 22, and targetSdkVersion 22, DELETE_FAILED_INTERNAL_ERROR doesn't happen again, Could somebody tell me why?
I can answer the second question. RC1 was just released, though the documentation has not been updated yet. It will read:
dependencies {
classpath "com.android.tools.build:gradle:1.3.0-beta4"
classpath "com.android.databinding:dataBinder:1.0-rc1"
}

Upgrading project to Android Studio 1.0 (Gradle problems)

Just to start I'm very new to android development/android studio/gradle so forgive me if I'm asking a stupid question.
My team has been working on a project with the beta version of android studio, I've just installed the new version (1.0) and i've imported our project from the github remote repo.
When trying to sync the project with gradle i get the error: Gradle version 2.1 is required. Current version is 2.2.1. It recommends that I change the distributionUrl in gradle-2.1 but when I do I get the error that the gradle plugin requires 2.2.1.
The question is why is my project requiring 2.1 and where can I change this?
Here is my gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.<teamName>.<projectName>"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript{
dependencies{
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
in the gradle-wrapper.properties use the following
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
in build.gradle use
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
also replace
runProguard false
with
minifyEnabled true
I hope this can help
I was having the same issue that you were and had made the exact same updates as described in the Google docs.
The error I was making was editing my app module's build.gradle, and not the project's build.gradle in the root of the project folder for the com.android.tools.build version.
Here's the updated PROJECT's build.gradle file that I'm using that works.
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
compileSdkVersion = 21
buildToolsVersion = "20.0.0"
minSdkVersion = 15
targetSdkVersion = 21
}
allprojects {
repositories {
jcenter()
}
}
To change the gradle distribution used go to this file: {Project folder}/gradle/wrapper/graddle-wrapper.properties.
Then change the distributionUrl to use 2.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

The project is using an unsupported version of Gradle

I am following this tutorial in Android Studio.
When trying to Import the project, I get a dialog saying:
"The project is using an unsupported version of Gradle."
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)"
It also fails if I select the wrapper method by stating:
"Plugin with id 'com.android.application' not found.
Here is what Parse's gradle looks like:
apply plugin: 'com.android.application'
repositories {
mavenCentral() }
dependencies {
compile 'com.parse.bolts:bolts-android:1.1.3'
compile fileTree(dir: 'libs', include: 'Parse-*.jar') }
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
My project's Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "id.goes.here"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
You generally have two build.gradles in your project:
A top level build.gradle in your project's root that contains buildscript {} and allprojects {} sections. This contains the project-wide configuration.
An app module build.gradle (located in your app's module folder) that contains the configuration for your android application. This one contains the android {} section.
Open up your top level build.gradle, and look at the Android Gradle plugin version (it will look something like classpath 'com.android.tools.build:gradle:1.0.0-rc3').
If the plugin is at version 0.13.0 or higher, you need to make sure you are using Gradle 2.1 or newer.
If the plugin is below version 0.14.4, you cannot use Gradle 2.2+.
Before going further, you need to find out whether you are using a local gradle distribution or the wrapper. To do so, go to File > Settings, then search for "Gradle." If "Use local Gradle distribution" is selected, either update your local Gradle to a supported version or switch to using the wrapper.
If you are using the wrapper, the configuration for the Gradle version is located under <your-project>/gradle/wrapper/gradle-wrapper.properties. This file contains a line that will look something like this: distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
. Simply change the version at the end to a supported version.
Studio typically will offer to update the wrapper for you if you click on the error telling you that it is not a supported version.
I resolve this issue by syncing project with gradle files.
In android studio from menu open File option and click option sync project with gradle files.
In the project build,gradle file
Replace
runProguard false
With
minifyEnabled true

Categories

Resources