Android Studio not recognizing ShortcutManager class - android

I'm looking into shortcut creation with Android O. Unfortunately Android Studio is not recognizing the ShortcutManager class:
In the gradle file I have set as a dependency:
compile 'com.android.support:appcompat-v7:25.3.1'
In the gradle file I have these versions set:
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 25
targetSdkVersion 25
I have followed the steps in this SO response and executed File => Invalidate Caches / Restart...
Unfortunately Android Studio continues to not recognize the class.
Information on my version of Android Studio:
Android Studio 2.3.2
Build #AI-162.3934792, built on April 21, 2017
JRE: 1.8.0_112-release-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Attempting to manually import the class is not successful:

In addition to assuring that Android Studio version number is at 2.3, the breakthrough I had was finding this documentation for migrating to Android O. In the section "Get the Android O SDK" it prescribes both platform and tool updates that are initiated by launching from the Android Studio menu Tools > Android > SDK Manager.
Here's a screenshot for which platform components I needed to update:
When combined with the required tools updates, these were combined updates required:
Then, you must take care to follow the required updates to your build configuration outlined in the section "Update your build configuration", an element that I had missed was the maven update:
android {
compileSdkVersion 26
buildToolsVersion '26.0.0-rc3'
defaultConfig {
targetSdkVersion 26
}
...
}
dependencies {
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
}
// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}

Related

Error building an Android package "Installed Build Tools revision 31.0.0 is corrupted." [duplicate]

I'm on Android Studio 4.2.2. I created a new project and haven't added anything to the starter code and whenever I click build or run, I get this error:
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
I've looked at other posts' suggestions, but neither of those solutions worked. Here's what I've tried:
SDK Manager → SDK Tools → check "Show package details", uncheck 31.0.0, and click "Apply" → Uninstall 31.0.0 → check 31.0.0 and reinstall it
In SDK Manager, deselect 31.0.0 and try installing an older version (e.g., I've tried 30.0.3) and update "buildToolsVersion" in build.gradle to the installed version
Went to Project Structure → Properties and verified that 31.0.0 is selected for "Build Tools Version" and "Compiled SDK Version"
Manually remove the stuff in the build-tools folder; i.e., rm -rf /path/to/android/sdk/build-tools/31.0.0 (it doesn't end in "-rc" like some other posts have described)
Restart Android Studio
Reinstall Android Studio
I'm an Android noob just trying to set up a Hello, World! project, and it really shouldn't be this hard.
First of all, I faced this issue in Android Studio 4.2.2 and you do not need to downgrade the SDK build tool from 31 to 30 or change compile SDK version.
The main problem is the two files missing in SDK build tool 31 that are:
dx.bat
dx.jar
The solution is that these files are named d8 in the file location so changing their name to dx will solve the error.
The steps are below.
For Windows
go to the location
"C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0"
find a file named d8.bat. This is a Windows batch file.
rename d8.bat to dx.bat.
in the folder lib ("C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0\lib")
rename d8.jar to dx.jar
Remember AppData is a hidden folder. Turn on hidden items to see the AppData folder.
For macOS or Linux
Run the following in the Terminal:
# change below to your Android SDK path
cd ~/Library/Android/sdk/build-tools/31.0.0 \
&& mv d8 dx \
&& cd lib \
&& mv d8.jar dx.jar
Now run your project.
The same problem was encountered and solved with a few line changes.
Check the Project code panel, and go to Gradle Scripts → build.gradle file,
Change three places from 31 to 30: compileSdkVersion, buildToolsVersion, and targetSdkVersion
You'll notice a lightbulb hit occurring on modified lines. Click and choose sync [to version 30]. Android Studio will automatically download BuildTool V30 and change project settings.
Now run the app. It works for me.
The point is not to downgrade target API level, but to build exactly for API level 31 to prepare and test an app for Android 12!
It looks like DX is removed from SDK in favor of D8.
It looks like that Android Gradle plugin 4.x is not aware of that.
At the moment I see only two solutions:
To stay with AGP 4.x, one should copy DX from 30.0.3 to 31.0.0
Upgrade AGP to 7.x
The solution for Mac is pretty similar to Windows, yet not fully conclusive from reading the Windows solution. The paths and file names are different, but the problem is basically the same.
Open the terminal application and type the commands below
Hit Enter after every command line you type to execute the command
Type cd /Users/admin/Library/Android/sdk/build-tools/
Attention: Your user directory name may be different from "admin"
Navigate to the corresponding version: type cd 31.0.0
Type cp d8 dx
Type cd lib
Type cp d8.jar dx.jar
This fixed my issues on macOS v10.13.6 (High Sierra).
After changing these settings, it seems to work fine. I downloaded SDK version 30 from SDK Manager.
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.anurag.myapplication"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
In order to fix the issue, firstly go to the following location:
C:\Users\User\AppData\Local\Android\Sdk\build-tools\31.0.0
Then find the file d8 (Windows batch file) and rename it to dx.
Then go to:
C:\Users\User\AppData\Local\Android\Sdk\build-tools\31.0.0\lib
Then find the file d8 (Executable Jar File) and rename is to dx.
Your problem will be solved now.
For those who are using Azure DevOps and require things to work with 30.0.3 you need to uninstall version 31.0.0
I added this to my pipeline to make my builds work again.
- bash: |
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'
The environment variable $ANDROID_SDK_ROOT is in the preset variables
Version 31.0.0 itself is corrupt, and we need to downgrade to 30.
Steps I followed for the same:
Open project structure → press Ctrl + Alt + Shift + S
Go to Module → properties → *Compiled SDK Version: 30 Build Tools Version: 30.0.2
Go to Default Config → Target SDK Version: 30
Apply and Close.
Menu Tools → SDK Manager
Uncheck API 31 to uninstall and check Android 11.0(R) to install (30.0.3) in my case.
Apply.
If you carefully look at the logs you'll see:
Build-tool 31.0.0 is missing DX at path-to-sdk\build-tools\31.0.0\dx.bat
You can try copying it from previous versions, but that won't lend well if you have to tell your entire team to do the same and it still fails on your server pipeline. This happened to me on 31.0.0-rc5 release as well.
Change your Gradle build from:
android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
applicationId "com.example.eg"
minSdkVersion 23
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
to:
android {
compileSdk 31
defaultConfig {
applicationId "com.example.eg"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
This will work.
In file build.gradle (Module: HelloWorld.app):
compileSdkVersion 30
buildToolsVersion "30.0.0"
targetSdkVersion 30
Change the above configuration to this:
I downloaded dx.bat file from https://android.googlesource.com/platform/dalvik/+/master/dx/etc/dx.bat.
I put it in \build-tools\31.0.0 and then downloaded the dx.jar file (which was also missing, by the error message I got)
from http://www.java2s.com/Code/Jar/d/Downloaddxjar.htm.
I put it into directory \build-tools\31.0.0\lib.
Then it worked.
I don't have enough reputation for commenting yet, but there is the solution with symbolic links for Windows, and I'd like to add that it works for macOS, too.
That's the command for Mac's terminal:
ln %ANDROID_HOME%/sdk/build-tools/31.0.0/d8 %ANDROID_HOME%/sdk/build-tools/31.0.0/dx && ln %ANDROID_HOME%/sdk/build-tools/31.0.0/lib/d8.jar %ANDROID_HOME%/sdk/build-tools/31.0.0/lib/dx.jar
You don't need to specify android.buildToolsVersion from Build Tools 27.0.3 or higher.
Build Tools 27.0.3 or higher. Keep in mind, you no longer need to
specify a version for the build tools using the
android.buildToolsVersion property—the plugin uses the minimum
required version by default.
Source (Developers.Android)
First of all, guys if you're facing these types of issues you can try the solution where we need to shift 31 to 30.
And after that some important steps are required to do:
Step:
To open project structure > Press Ctrl+Alt+Shift+S
Open Module > properties > Compiled Sdk Version: 30
Build Tools Version: 30.0.2
Click on Default Config > Target SDK Version: 30
After that, your task is not, in some cases still, you can see this configuration is not accepted, you need to do these steps also:
Go to the top Right area, and click on SDK Manager Icon.
Select Android SDK > image 1 where you need to tick all Android version which you need*
After tick Click OK and then install.
Android SDK > SDK Tool > right down side > show Package detail >
tick on 30.0.2 option and then install.
image 2 > select 30.0.2
5) Now done click OK install> apply your good to go.
To uninstall only Build-Tools 31.0.0 from Android Studio
Navigate to:
Configure -> SDK Manager -> SDK Tools [tab] -> Show Package Details [check box]
click on Android SDK Build-Tools 31
uncheck 31.0.0
and Hit OK
I answered this question over here, but I'll copy/paste the answer as it's relevant:
As pointed out in other issues, the problem is that dx (or dx.bat) is no longer available. This was a purposeful change announced in 2018.
Suggested resolutions of renaming d8 to dx or copying it from build tools 30.0.0 will resolve the issue, but dx isn't likely to return. So you'll be stuck patching every build tools installation on every developer's machine going forward.
The more forward-compatible solution is to upgrade your Android Gradle plugin. This isn't as straightforward as just changing the number in Gradle, but I find that Android Studio's upgrade process works well for my projects. If you open your project-level build.gradle file, open up the quick fixes menu from the lightbulb over your
dependencies{
classpath 'com.android.tools.build:gradle:...'
section. From here, choose to upgrade to the newest possible version (not just 4.x in my case).
Then I run the upgrade steps for literally everything:
My issue was Unity-specific though: I needed to use the system Android SDK rather than the one built in, but Unity itself likes to regenerate these build files and will just grab the newest buildtools it can find. To reduce manual steps and to avoid having to export my project, I instead chose to generate my module-level build.gradle files from my "Player Settings>Publishing Settings" window:
Both files will have a line that looks like:
buildToolsVersion '**BUILDTOOLS**'
Which you can replace with:
buildToolsVersion '30.0.0'
From Unity, this lets me build and deploy projects as I had before without modifying the buildtools installation.
I unistalled and installed the 31.0.0 package and still it was showing the error.
I used RC2 build tools and it compiled and ran fine without downgrading to SDK version 30.
In file app/build.gradle:
buildToolsVersion "31.0.0-rc2"
My Android Studio Arctic Fox 2020.3.1 Patch 2
with
downloaded Android 12 and Android SDK Build-Tools 31 in Android SDK
working with buildToolsVersion "31.0.0"
build.gradle (Project)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module)
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "com.example.android12"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
gradle-wrapper.properties
#Fri Sep 10 13:52:36 ICT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Press Ctrl+Alt+Shift+S to open project structure. The select Module from the left.
Open Properties tab and change the followings:
Compiled Sdk Version: 30
Build Tools Version: 30.0.2
After that open Default Config tab and change:
Target SDK Version: 30
I unchecked 31 under the SDK Manager, clicked Android 11.0(R) to revert back to 30, and updated the Build Gradle (project) to change compileSdkVersion and targetSdkVersion from 31 to 30.
I also had to update buildToolsVersion to "30.0.2" instead of 30. Now it works.
Try to reinstall the SDK 31 again and restart Android Studio, it should work. Otherwise, from the SDK Manager, install the SDK 30 to the System and configure the app build Gradle file as
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
targetSdkVersion 30
}
It's a conflict issue with Android studio and SDK 31.
Convert your build.gradle file like this:
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
There are so many wrong and misleading answers here.
The only thing you should really do is to install the latest Android Studio Beta version if you're using the Beta SDK. With the latest Android Studio Beta comes support for the latest AGP, which correctly supports SDK 31.
In build.gradle(Module) file. Change the following settings.
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.recycleview.mvvm"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
I first followed user16475264's answer, but the real issue (at least in my case) turned out to be the version of the AGP (Android Gradle Plugin). So, after upgrading to v7, I rolled back my changes for both, the executable and the JAR file: dx -> d8 in ~/Library/Android/sdk/build-tools/31.0.0. This worked
Upgrade gradle to 7.0.2 might helps
For android 12 target sdk API 31
compileSdkVersion 31
buildToolsVersion 31.1.0
The Android gradle plugin(AGP) should have minimum version set as
7.0.2 or above
android gradle wrapper version could be set
gradle-7.2-bin.zip
With above configuration the build error will be resolved and you no need to downgrade the build tool version to 30.0.2
Also, if you face and intellij annotations related build error, add below configuration in your app/build.gradle file
configurations {
compile.exclude group: 'com.intellij', module: 'annotations'
implementation.exclude group: 'com.intellij', module:'annotations'
}
M1 Macbook solution:
go to Terminal:
Step1 :
cd ~/Library/Android/sdk/build-tools/31.0.0
Step2:
mv d8 dx
Step3:
mv d8.jar dx.jar
Step 4: Rebuild your project in Android studio. or simply run your project from android studio
Note if you are running a different version other than 31.0.0 then change the version in the step 1 command line.
There are multiple solutions to this issue though one which should logically fix it does not work i.e. uninstalling build tool version 31.0.0 and reinstalling that. This solution does not work and Android Studio team probably need to look into it.
Currently which seems to work is:
Solution 1 (Downgrade Build Tool Version being used in project)
Check the Project code panel, and go to Gradle Scripts –> build.gradle file,
Change 3 places: compileSdkVersion, buildToolsVersion, targetSdkVersion from 31 to 30
You’ll notice a lightbulb hit occurring on modified lines, click and choose sync [to version 30]. The Android Studio will automatically download BuildTool V30 and change project settings.
Solution 2 (Get missing dx.bat and dx.jar files from previous version build tools)
Build-tool 31.0.0 is missing DX at path-to-sdk\build-tools\31.0.0\dx.bat and
Build-tool 31.0.0 is missing DX at path-to-sdk\build-tools\31.0.0\lib\dx.jar
You can try copying it from previous version build tools. I did from Version 30.0.3 and it worked for me.

With upgrade to Android Studio 3.5 now get error: package com.google.android.maps does not exist

I have a project using the long since deprecated Maps V1 API, on which I have put in a lot of work and I need it.
I have just upgraded Studio to 3.5 and my current version for which I accepted the recommendations to upgrade the gradle plugin and gradle to versions 3.5.0 and 5.4.1 can't find the maps package on line such as:
import com.google.android.maps.GeoPoint;
Fortunately I have a previous version which barely differs and I didn't accept the upgrade recommendations for the plugin and gradle. The versions are 3.4..2 and 5.1.1. It builds successfully.
The relevant parts of my build.gradle (which is the same for both projects) are:
apply plugin: 'com.android.application'
android {
signingConfigs {
...
}
compileSdkVersion 'Google Inc.:Google APIs:15'
//compileSdkVersion 15
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "uk.co.secret.gridmaps"
minSdkVersion 8
targetSdkVersion 10
}
}
dependencies {
implementation 'org.osmdroid:osmdroid-android:5.2#aar'
// NBT TRY 26 AUGUST 2019
//implementation 'com.google.android.gms:play-services.maps:15.0.0'
}
Uncommenting the last line (as suggested in similar questions) doesn't help either:
ERROR: Failed to resolve: com.google.android.gms:play-services.maps:15.0.0
All suggestions will be gratefully received.
UPDATE 19:00 GMT
I can fix this in a very dirty hard-coded way by adding the line
implementation files ('libs/googleapi21maps.jar')
to the dependencies section of build.gradle. That jar file is just a renamed version of C:\dev\tools\android-sdk-windows5.0\add-ons\addon-google_apis-google-21\lib\maps.jar from my old Windows eclipse project
Given that maps API V1 is dead, it does no harm but it's not elegant at all.
Also given that gradle 5.1.1 can find the package without resorting to this inelegant method, why can't gradle 5.4.1?
Update 2
It builds OK but when I invoke an activity that uses the android.maps, it crashes with an IncompatibleClassChangeError. I changed the version of the libs.jar to 15 with no improvement.
I need to make the latest gradle have backward compatibility with legacy code, even if I have to give an explicit reference to the library that gradle 5.1.1 retrieved.
The compileSdkVersion looks stange, that should be eg. 28 (or 29).
And the current play-services-maps version is 17.0.0:
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-maps:17.0.0"
mavenCentral() also has a newer version of osmdroid-android:
// https://mvnrepository.com/artifact/org.osmdroid/osmdroid-android
implementation "org.osmdroid:osmdroid-android:6.1.0"

The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25; please update

I am getting this error on the latest version of Android Studio and while I have installed both Android SDK Platform API 25 and Android SDK Build-Tools 25.
As Vishnu said, For me updating Android studio and Gradle didn't fix the problem.
I navigated to Tools -> Android -> SDK Manager and selected BuildTools and checked for the updates related to platform tools. After updating and installing those, fixed my problem.
And for one my friends, the issue got resolved after following the above steps and then navigating to Help->Check for updates-> and installing all the available updates.
Attached Screenshot for the same.
I am facing similar issue after upgrading Android Studio to 3.0. A very simple way to fix this is go to
Tools -> Android ->SDK Manager -> SDK Tools
There look for Android SDK platform tools and update it. (Screenshot attached)
Thats it, you don't have to change any other gradle setting.
I had a similar problem. Updating Android Studio to version 2.2.2 (latest at the time of this writing) and Gradle version to 2.2.2 (latest at the time of this writing) in project_name/build.gradle file fixed this issue.
For reference, this is my config in project_name/app/build.gradle file:
minSdkVersion = 19
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = "25"
supportLibraryVersion = "25.0.0"
And this is my dependencies in project_name/build.gradle file :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Open AndroidMainfest.xml
Click the red icon => Disable inspection => Error is gone
I face same problem but when I swap
buildToolsVersion "25.0.0"
to first line then problem solved. Then the final app grade become:
android {
buildToolsVersion "25.0.0"
compileSdkVersion 25
defaultConfig {
applicationId "com.***"
minSdkVersion 15
targetSdkVersion 25
versionCode 0
versionName "0.0.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Update your android sdk platform-tools to the revision from 24.0.4 to 25.x.x on sdk manager. Then android studio click File->Invalidate Caches/Restart...
The error must be gone now.
Try to update
Android SDK Build-Tools
Android SDK Platform tools
Android SDK Tools
Android Support Repository
Google Play Services
Google repository
etc to the latest version. Error must be gone.
Go to Gradle(app) and replace
buildToolsVersion "25"
to
buildToolsVersion "24.0.4" // Or Latest installed gradle version
also if targetSdkVersion is 25 then make this 24
On command line
./sdkmanager "platform-tools" "platforms;android-26"
./sdkmanager --list
Check if you have update to latest release

Which gradle version to use with the latest Android Studio?

Could not find a definite resource as of which gradle, gradleplugin versions to use with a specific / latest AndroidStudio version.
UPDATE:
Best official resource answering the question: http://tools.android.com/tech-docs/new-build-system/version-compatibility
Official documentation is what you need: https://developer.android.com/tools/revisions/gradle-plugin.html
UPDATE JANUARY 2017
Android Studio 2.2.3
Gradle 2.2.3 or higher.
Build Tools 25.0.2 or higher.
Using Android Studio 1.3 with this dependencies:
Gradle 2.2.1 or higher.
Build Tools 21.1.1 or higher.
Also, Gradle 2.7 was release 14th September 2015: http://gradle.org/
This would be more of a comment but I haven't accumulated enough points as of yet.
If you've updated your Android Studio to 1.3.2 version then I would suggest using Build Tools Version 23.0.0 and compile API 23 Android 6.0.
In your top level gradle file;
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "your.package.name"
minSdkVersion 15 // min sdk can be any sdk you want to target
targetSdkVersion 23 // target compiled version
}
}
As for Gradle Version - 2.4 or higher up to latest 2.7.
In your App gradle file;
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Execution failed for task ':app:compileDebugAidl': aidl is missing

I installed Android Studio on my computer. I created a new project but that got me the error below. What can I do?
Error:Execution failed for task ':app:compileDebugAidl'.
> aidl is missing
My Android Studio version is 1.1.0.
This is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "24.1.2"
defaultConfig {
applicationId "com.example.jo.cloning_a_login_screen"
minSdkVersion 13
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:22.0.0'
}
In my case I downloaded version 22 of Android M and Android 5.1.1 using Android Studio 1.2.1.1 but when I try to do a Hello World this same error showed me
So the solution for me was doing right click in app like the image below and choose "Open Module Settings"
then there you have 2 options. I've changed both with the last version I had.
Compile SDK version to API 21 Lollipop
and Build Tools Version to 21.1.2
Finally clean the project and Build
UPDATED
TO Get Android Studio 1.3 follow these steps
Open the Settings window by choosing File > Settings.
Choose the Appearance & Behavior > System Settings > Updates panel.
On the Updates panel, choose the option Automatically check updates for: Canary Chanel.
On the Updates panel, select Check Now to check for the latest canary build. Download and install the build when you are prompted.
Then you'll have something like this to update your Androud Studio to 1.3 and with this you can test Android M
Update: Real Cause
This bug happens when the versions of SDK, Build Tools and Gradle Plugins doesn't match (in terms of compatibility). The solution is to verify whether you are using the latest version of them or not. The gradle plugins are placed in the build.gradle of the project, and the other versions are on the build.gradle of the module. For example, for SDK 23, you must use the Build Tools 23.0.1 and gradle plugins version 1.3.1.
It has been fixed two days ago, so you can use:
buildToolsVersion '23.0.0 rc2'
with the newest android gradle plugin:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
Note:
I had some weird problems with gradle 2.4 distribution, but trying to build the project again has fixed that for me.
EDIT
There is a newer version of build-tools 23, so you should probably use:
buildToolsVersion '23.0.0 rc3'
EDIT 2
And yet again, there are newer version of both gradle plugin and build-tools, so you can switch to using:
classpath 'com.android.tools.build:gradle:1.3.0'
and
buildToolsVersion '23.0.0'
I had a similar error with a fresh install of Android Studio 1.2.1.1 attempting to build a new blank app for API 22: Android 5.1 (Lollipop).
I fixed it by simply changing the Build Tools Version from "23.0.0 rc1" to "22.0.1" and then rebuilding.
On Windows, F4 opens the Project Structure and the Build Tools Version can be set in the Modules > app section:
I think all this does is change the setting in the build.gradle file in the app but I didn't want to change that manually just in case it does something more.
I tried to uninstall/install and it did not work. I am running OSX 10.10.3 with Android Studio 1.2.1.1 on JDK 1.8.0_45-b14 and the solution I found to work is similar to Jorge Casariego's recommendation. Basically, out of the box you get a build error for a missing 'aidl' module so simply changing the Build Tools Version to not be version 23.0.0 rc1 will solve your problem. It appears to have a bug.
UPDATE
After commenting on an Android issue on their tracker (https://code.google.com/p/android/issues/detail?id=175080) a project member from the Android Tools group commented that to use the Build Tools Version 23.0.0 rc1 you need to be using Android Gradle Plugin 1.3.0-beta1 (Android Studio comes configured with 1.2.3). He also noted (read the issue comments) that the IDE should have given an notification that you need to do this to make it work. For me I have not seen a notification and I've requested clarification from that project member. Nonetheless his guidance solved the issue perfectly so read on.
Solution: Open your build.gradle for your Project (not Module). Find the line classpath com.android.tools.build:gradle:xxx under dependencies where xxx is the Gradle Plugin version and make the update. Save and Rebuild your project. Here is the Android Gradle docs for managing your Gradle versions: https://developer.android.com/tools/revisions/gradle-plugin.html
I was able to get build to work with Build Tools 23.0.0 rc1 if I also opened the project level build.gradle file and set the version of the android build plugin to 1.3.0-beta1. Also, I'm tracking the canary and preview builds and just updated a few seconds before, so perhaps that helped.
// 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.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Quick fix that worked for me:
Right click on project->"Open Module Settings"->Build Tools Version change to: 22.0.1
To build your application without aidl is missing error with compileSdkVersion 23 and buildToolsVersion "23.0.1" you should specify latest versions for Android Gradle plugin (and Google Play Services Gradle plugin if you are using it) in main build.gradle file:
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.google.gms:google-services:1.3.1'
}
}
I had the same error i fixed it by going to the build.gradle (Module: app) and changed this line from :
buildToolsVersion "23.0.0 rc1"
to :
buildToolsVersion "22.0.1"
You will need to go the SDK Manager and check if you have the 22.0.1 build tools. If not, you can use the right build tools but avoid the 23.0.0 rc1.
Essentially Matt Daley/Johnny Mohseni's solution worked for me.
I faced exactly the same problem on a fresh Android Studio V 1.2.1.1 installation. I created a new project (blank activity) and straightaway god this build error.
Error:Execution failed for task ':app:compileDebugAidl'.
> aidl is missing
As suggested, changing the gradle dependency from 1.2.3 to 1.3.0-beta1 fixed it.
classpath 'com.android.tools.build:gradle:1.3.0-beta1' // <--- WORKS!
//classpath 'com.android.tools.build:gradle:1.2.3' // <--- default - failed
Once 1.3.0-beta1 change was saved, I got a prompt to upgrade dependencies. Upon accepting the request to upgrade, the gradle build status bar at the bottom tracked the packages being synced. When that completed, the build was automatically triggered and completed successfully.
Use your file browser and copy-paste the IInAppBillingService.aidl into /app/src/main/aidl/com/android/vending/billing/
The problem was actually in the version Android Studio 1.3 updated from the canary channel. I updated my studio to 1.3 and got the same error but reverting back to studio 1.2.1 made my project run fine.
buildtools layout in 23.0.0.rc2 was reverted
so to be able to use it, you need to upgrade the plugin to 1.3.0-beta2 or higher as i show below:
I am working with sdk 23.1.0 and gradle 1.3.1. I created a new project edited nothing and got the aidl error. I went into my project gradle file and changed tool to 22.0.1 instead of 23.1.0 and it worked:
compileSdkVersion 23
buildToolsVersion "22.0.1" //"23.1.0"
Check if you actually have installed the buildVersionTools you are using. In my case I tried 25.0.1 whilst I only had 25.0.2.
To check it go to the SDK Manager, clicking the icon:
Then click Launch Standalone SDK Manager at the bottom:
Now check whatever you need and install packages.
Hope it helps!

Categories

Resources