My first program in Android Studio (Hello world) - android

Everyone!!
I try to launch my first program in Android Studio. I have got error, something like this:
Failed to refresh Gradle project 'Hello World'
Cause: failed to find Build Tools revision 16.0.2
Please install the missing Build Tools from the Android SDK Manager.
Open Android SDK Manager
I installed Android SDK :
Honestly i don't see in my installations Android SDK Build-tools revision 16.0.2
I have googled to download this revision, but i couldn't find any refs... ??
Can you help me with this problem?

Looks like you have a very old version of Android Studio. Have a look at the android section in the build.gradle file in your project. Your screenshot shows that you have build-tools 19.0.3 installed, so change the appropriate line to
buildToolsVersion "19.0.3"
And update your Android Studio so it won't produce outdated build.gradle files in the first place!

Find the root build.gradle file. It will look something like this:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 4
versionName "0.9.4"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Change the buildToolsVersion to 19.0.3 and be sure you installed this build tools version. The latest version of Android Studio should give a notification if you use an outdated version of buldToolsVersion.
Small side note: Please be aware that Android Studio is still in beta. Not everything works perfectly at the moment. Nevertheless, I think it works already a lot better than Eclipse.

Related

Change build tools to 21

Warning : Project is building density based multiple APKs but using tools version 19, you should upgrade to build-tools 21 or above to ensure proper packaging of resources
Okay this above is the 2 errors that come up in my gradle console when I run my app. The app does not run and just stops. How would I change the build tools to 21?
In Android Studio :
Tools -> Android -> Sdk Manager and install build-tools 21.0.2.
change your build.gradle in android block
compileSdkVersion 21
buildToolsVersion "21.0.2"

failed to find target with hash string 'android-22'

I have updated android studio with latest version and then after googling I also updated Android SDK with API 18 but still it gives the same error.
Just click on the link written in the error:
Open Android SDK Manager
and it will show you the dialogs that will help you to install the required sdk for your project.
Open the Android SDK Manager and Update with latest :
Android SDK Tools
Android SDK Build Tools
Then Sync ,Re-Build and Restart Your Project
Demo Code for build.gradle
compileSdkVersion 21 // Now 23
buildToolsVersion '21.1.2' //Now 23.0.1
defaultConfig
{
minSdkVersion 15
targetSdkVersion 19
}
Hope this helps .
Okay you must try this guys it works for me:
Open SDK Manager and Install SDK build tools 22.0.1
Sync gradle That'all
I modified build.gradle compileSdkVersion to 23 from 22 and targetSdkVersion to 23 from 22.
My API level was 23. I had to update the API version to 23 as well.
I had to import my project from Eclipse to Android Studio. It worked for me.
I had similar issue. I updated android studio build tools and my project didn't find "android-22". I looked in android sdk manager and it was installed.
To fix this issue I uninstalled "android-22" and installed again.
I created a new Cordova project, which created with latest android target android level 23. when i run it works. if i changed desire android target value from 23 to 22. and refresh the Gradle build from the Andoid Studio. now it's fail when i run it. i got the following build error.
project-android /CordovaLib/src/org/apache/cordova/CordovaInterfaceImpl.java
Error:(217, 22) error: cannot find symbol method requestPermissions(String[],int)
I changed the target level in these files.
project.properties
AndroidManifest.xml
and inside CordovaLib folder.
project.properties
However, i also have another project which is using the android target level 22, whenever i run that project, it runs. Now my question is can we specify the desire android level at the time of creating the project?
I think you should install API 18 from android sdk if not already installed, otherwise you can try "invalidate caches and restart" (Find: File->invalidate caches and restart).
Change
compileSdkVersion 18
minSdkVersion 10
targetSdkVersion 18
in build.gradle in your app directory/module
Or Download Latest API Version
In sdk Manager download android 5.1.1, it worked for me
Open project.properties file and change the line with target=android-22 to the desired value.
For example:
target=android-19

How to debug the issue Unable to install the app from APK in Android

I have an Android Application.
My QA reported that when they try to deploy the Build APKs in various emulators, the apk is not getting installed in OS versions less than 4.3.3.
However, it's installing properly in any Emulator or device with versions greater than 4.3.3
But to try and debug this issue, I ran the application from "Android Studio" on the emulators of version less than 4.3.3, But the application gets deployed properly.
Does this mean it's not a programming issue, but a build file or packaging issue?
Here's my gradle snippet
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId 'com.intuit.qm2014'
minSdkVersion 14
targetSdkVersion 21
}
How to debug/fix these type of issues?
Try to install on problem devices with command
adb install path_to_apk
and see output.
Also see logcat output on problem devices (possibly filter with tag "Package Manager") and you'll see some info about installation failed.
I realised that there was a mistake in my build.sh script which our Jenkins Job was executing to create builds.
I had to fix the build.sh file to fix the signing to get it to work properly.
Check your minsdk and targetsdk in AndroidManifest.xml
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="22"/>
This is just sample to check, place your appropriate values sdk version.

AndroidStudio: Failed to sync Install build tools

Going crazy with this error from about a couple of hours.
The error is:
failed to find Build Tools revision 23.0.0 rc1
But I think to have all update (also the release candidate!)
This is the image: thank you.
Go to File > Project Structure > Select Module > Properties you will landing to this screen
Select Build Tools Version same as version selected in Compile Sdk Version.
Hope this will resolve your issue.
I could fix it by changing it to
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
}
in build.gradle file
I had the same issue, with Build Tools revision 24.0.0-rc4. The fix was to install the package using the command line.
~/Android/Sdk| ls -1 build-tools/
23.0.3
24.0.0-rc4
~/Android/Sdk| ./tools/android list sdk -a | grep "SDK Build-tools"
4- Android SDK Build-tools, revision 24 rc4
5- Android SDK Build-tools, revision 23.0.3
6- Android SDK Build-tools, revision 23.0.2
7- Android SDK Build-tools, revision 23.0.1
8- Android SDK Build-tools, revision 23 (Obsolete)
...
~/Android/Sdk| ./tools/android update sdk -a -u -t 4
...
~/Android/Sdk| ls -1 build-tools/
23.0.3
24.0.0-preview
24.0.0-rc4
(note that 4 in the android update sdk command above refers to the preceding list's number for the desired version, found at the beginning of the line).
The directory build-tools/24.0.0-rc4/ had been created when I installed the package from Android Studio's SDK Manager. The above method created build-tools/24.0.0-preview/.
My app-level build.gradle script uses the -rc4 version, as specified in the setup guide:
android {
compileSdkVersion 'android-N'
buildToolsVersion '24.0.0-rc4'
}
I do not understand the correlation between -rc4 and -preview or why specifying 24.0.0-rc4 picks up the -preview package, but it did fix the issue for me.
I have the same problem.
i have solved this issue by the following point.
First one is go to inside build.gradle app file and change this
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
}
with this one
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
}
I hope this will solve your issue.
I had the same problem and fixed it by going to File->Project Structure->Project and changing the Android Plugin Version to 1.3.0-beta1
Hope this helps!
I faced the same issue today,
And solved it easily by following points
1) Start the StandAlone SDK manager (To open the standalone sdk manager - Tools>Android>SDKManager> at Bottom YOu will see a link to launch StandAlone SDK manager)
2) Delete tha package of SDK Build Tools that you have already installed for e.g 24.0.0 rc4.
3) Close the standalone SDK manager then Restart Android Studio.
4) Once after restart the gradle will start building the project and you will get an alert download the package of SDK build tool and Sync. CLick on that and you will start downloading like that...
I hope this helps
I had the same problem, in my cases this happened because I changed the time on my computer to load .apk on google play. I spent a few hours to fix "this" problem until I remembered and changed the time back.
One of the answers ask you to use buildToolsVersion 23.0.0, but you would get buildToolsVersion 23.0.0 has serious bugs use buildToolsVersion 23.0.3. I did that then I started getting message buildToolsVersion 23.0.3 is too low from project app update to buildToolsVersion 25.0.0 and sync again. So I did that and it worked , So here are the final changes.
Inside app's build.gradle change this
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
}
with this one
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
}
based on your screenshot I can see you have BuildTools ver 23.0.0 rc2 installed. So to get it right open up your gradle build file "build.gradle(Module:app)" and edit buildToolsVersion part like that:
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
}
In case you have multiple SDKs locations (might happen if you play around with multiple Android Studio versions and create new location for SDK, what I did), make sure to check the local.properties file (both of the project and of your module, if you have such structure) and check if the line sdk.dir=/home/yourSdkLocation points indeed to the SDK you want to use.
This was the reason it wasn't working for me and it has fixed this.
There may be some file access permission/restriction problems. First check to access the below directory manually, check whether your TARGET_VERSION exists, Then check the android sdk manager.
sdk/build-tools/{TARGET_VERSION}
Had the same problem. I my case the build.gradel(app) was missing buildToolsVersion "27.0.0". So I open a previously working project to determine the version and added this line buildToolsVersion "27.0.0". Now it works fine.
Hope this helps.
I was also facing the same problem with gradle. Now I have solved by installing the highlighted in red. To navigate on this page Open Android studio > Tool > Android > SDK Manager > Appearance & Behavior > System Settings > Android SDK > SDK Tools (from tab options) > Show Package details(check box on the right bottom corner). After installing these just refresh the gradle everything will be resolved.
In case you have error regarding 'SDK build-tools failed' while installing Android Studio, Then you can Download build-tools from - https://androidsdkmanager.azurewebsites.net/Buildtools
Go to File > Project Structure > Select Module > Properties
After that CLICK on your project which will shown in LEFT PANEL
Then Select Properties
Change Build Tool Version to 22.0.1
It works for sure
problem:
Error:failed to find Build Tools revision 23.0.0 rc2
solution:
File > Project Structure > click on Modules > Properties
Change Build Tool Version to 23.0.1
its work for me
enter image description here
Start the project structure( file>structure)
You can see:
on the left, modules list;
on the right, Properties>Build Tools Version
there maybe are more than one modules.
change "Build Tools Version" for every Module.
it works.

Android Studio update 0.5.3 - platform 'android-19' not found

Yesterday I opened Android Studio and it asked me to be updated. I now have v0.5.3, SDK 19 fully installed and gradle 0.9.+. I think this information is correct but I'm not fully aware how the gradle strategy works.
The problem is that my gradle apps stopped syncing and even when I create a brand new project it does not sync.
Here are the details:
Project's build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
App's build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
In SDK Manager I have all the builds installed including 19.+.
The error I get when syncing:
Failed to set up SDK
Error:Module 'app': platform 'android-19' not found.
Information:Double-click here to open Android SDK Manager and install all missing platforms.
I know that if I change
compileSdkVersion 19
to
compileSdkVersion 18
in the app's build.gradle it works... but I don't think that's the solution.
Thanks!
I had the same problem.
Deleting ~/.AndroidStudioPreview (on Debian GNU/Linux 'sid') fixed the problem. This directory was from an older version of AS (0.3.x). I don't know what the equivalent of the GNU/Linux ~/.AndroidStudioPreview is on Windows/Mac OS X/... (for Windows it's under C:\Users\<user>\.AndroidStudioPreview\).
Deleting the following fixed my problem -
~/Library/Caches/AndroidStudioPreview
~/Library/Logs/AndroidStudioPreview
~/Library/Preferences/AndroidStudioPreview
Update your Android SDK tools to version 22.6.2, and install android-19. It worked for me!
Go to your Module Settings and set project SDK.
Had this problem too in 0.5.3 and the only way I could fix it was to downgrade to 0.5.2.
Even though I added the SDK manually in the project structure window, it would not import android class files properly.
0.5.2 is available here: http://tools.android.com/download/studio/canary/0-5-2
Delete your .AndroidStudioPreview folder and run Android Studio again.
Unfortunately you will lose your settings.
I was able to just open the SDK Manager and install the updates it found. I had installed new things recently, yet it found six new packages to install. My guess is the new version of the SDK tools is what fixed the gradle problem. Works fine now. No downgrade, no hidden file deletions.
Wait, I was installing 0.5.4 not 3.
Just found out that updating the SDK platform 19 to revision 3 solved this problem for me.
For instance I'm using Android Studio 0.5.4 as well.
Go to the SDK manager and install Extras -> Android Support Repository
I had the same problem but my reason was because I had two SDK Managers and my Android Studio had the wrong SDK Manager directory.
The first SDK Manager was from my Eclipse-Android SDK that I installed a few years back. The directory it is located in is C:\Program Files (x86)\Android\android-studio\sdk
The 2nd SDK Manager was for my Android Studio. The directory it is located in is C:\Users\Gene\Android SDK\sdk
In Android Studio, go to File -> Project Structure. On the left tabs, choose “SDK Location”. Make sure you’re pointing the project at the right SDK Location.
If you need to access the SDK Manager for Android Studio in order to download more APIs, you might need to right click on “SDK Manager.exe” and then click “Run as administrator” in order for you to get it to work.
Whatever SDK Manager you are using, make sure you downloaded the API for it before you set "compileSdkVersion" (in gradle) to that API version.
I have the same issue just that i cannot change form version 19 to 18. Even though I have both versions installed. I use Android Studio version 0.5.4. One person at the office has the same setup without any problems on the same project. The fix with deleting the folder .AndroidStudioPreview works for one project, but then another I work on breaks.
Had the same problem after clean install of Android Studio 1.1.0 on OSX Yosemite. Deleting folders did not work. What did work was simply run sudo android, from terminal.
Easiest solution is to follow this.
After updating android studio create a brand new project. Then after successfully creating it open the graddle file(Module App).
Then check the Compile SDK version and Build Tools Version.
Then copy the same version numbers to your existing project and sync.
Click File - > Invalidate cash from the menu. It should upgrade your Android project in to the latest version resolving all the conflicts.
Build tools and Android SDK platform are two different things. When Gradle tells you that you miss android-19, it means that you did not get the latest version of the Android SDK (level 19)
You need to install this version.

Categories

Resources