39

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!

Supercelo
  • 399
  • 1
  • 3
  • 9
  • I am also seeing this from a fresh install of Android Studio this morning, "Error:Module 'app': platform 'android-19' not found". Screenshot: http://svm17250.vps.tagadab.com/img/as-issue.png Was you able to resolve this issue? – Dean Wild Mar 31 '14 at 13:45
  • 1
    I was only able to overcome the error by doing what I explained above: changing compileSdkVersion to 18 – Supercelo Mar 31 '14 at 15:49
  • Very weird... I hade to upgrade to android-19 for it to "work". – Ted Apr 01 '14 at 21:47
  • Fresh update did not solve the problem. On Android Studio 0.5.4 same problem. – Oknesif Apr 04 '14 at 07:09
  • The only thing I was able to do was going back to Eclipse. Sorry guys, but I can't point any right answer that worked for me... – Supercelo Nov 05 '14 at 23:19

13 Answers13

31

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\).

Tim Kist
  • 1,164
  • 1
  • 14
  • 38
cholm
  • 481
  • 3
  • 5
9

Deleting the following fixed my problem -

~/Library/Caches/AndroidStudioPreview

~/Library/Logs/AndroidStudioPreview

~/Library/Preferences/AndroidStudioPreview

A23
  • 1,596
  • 2
  • 15
  • 31
5

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.

enter image description here

Ajay S
  • 48,003
  • 27
  • 91
  • 111
  • 1
    I already had the android target installed, upgrading to the latest Android SDK tools did the job! Thanks. – Tom Susel Apr 10 '14 at 06:32
4

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

ade.se
  • 1,644
  • 1
  • 11
  • 11
2

Delete your .AndroidStudioPreview folder and run Android Studio again. Unfortunately you will lose your settings.

GeralexGR
  • 2,973
  • 6
  • 24
  • 33
2

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.

Rob
  • 11,446
  • 7
  • 39
  • 57
2

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.

Caue Ferreira
  • 287
  • 2
  • 7
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Andreas Lyngstad Apr 07 '14 at 19:35
  • 5
    I have to disagree with you, I believe it does answer the question. You see? I was having the very same problem. I updated my android studio and all my projects using gradle wasn't syncing anymore. I got the very same error message with was "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." then, I notice I had a new update for android-19 (I also was using this api) and after I applied this update (revision 3), all my projects that were using android-19 started to work again. – Caue Ferreira Apr 07 '14 at 23:21
2

Go to the SDK manager and install Extras -> Android Support Repository

bluehallu
  • 10,205
  • 9
  • 44
  • 61
1

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.

enter image description here enter image description here

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.

Gene
  • 10,819
  • 1
  • 66
  • 58
0

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.

  • I looked at the folder AndroidStudioPreview, does any body know how in sync the jdk.table.xml in folder AndroidStudioPreview/options should be with the Android SDK Manager. I have more android version installed in the Android SDK Manager, than is listed in the file jdk.table.xml. – user3505635 Apr 07 '14 at 07:52
0

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.

Daniele
  • 1,063
  • 1
  • 10
  • 22
0

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.

Neyomal
  • 1,589
  • 1
  • 12
  • 14
-1

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)

enter image description here

You need to install this version.

Thomas Bouron
  • 613
  • 3
  • 11
  • Thanks Thomas, but I also have the complete set of Android 4.4.2 (API 19) installed. And before you ask, I did restart the computer after that, just in case. – Supercelo Mar 31 '14 at 12:27
  • Humm another question then: Is the path to the SDK root folder (properties `sdk.dir`) is correctly set in the file `local.properties` ? – Thomas Bouron Mar 31 '14 at 12:31
  • Yes, I believe so: sdk.dir=C\:/Users//AppData/Local/Android/android-studio/sdk – Supercelo Mar 31 '14 at 13:38
  • @Supercelo Go the location indicated by the property `sdk.dir` + `sdk/platforms`. If you don't have a folder `android-19`, it means that something wrong in your sdk configuration. Otherwise, I cannot see anything else. – Thomas Bouron Mar 31 '14 at 13:43
  • I do have the folder C:\Users\\AppData\Local\Android\android-studio\sdk\platforms\android-19... Thanks for the help anyway, Thomas! – Supercelo Mar 31 '14 at 14:51
  • You're welcome, even if I cannot help you more. That's very strange though, I have the same configuration as yours (AS 0.5.3 - using API 19 as the compile version) but I have no trouble at all. It maybe worth to ping [Xavier Ducrochet](https://plus.google.com/u/0/+XavierDucrohet/posts) on the [Google Developer tools](https://plus.google.com/u/0/communities/114791428968349268860) community on Google+, he can probably help you more than me. – Thomas Bouron Mar 31 '14 at 14:57
  • Anyway, you can still set your `compileSdkVersion` to `18` as a workaround, it won't break anything nor be compatible with API 19 – Thomas Bouron Mar 31 '14 at 15:47
  • @Supercelo Jake Wharton just released a Gradle plugin that might interest you regarding your issue, [check it out on Github](https://github.com/JakeWharton/sdk-manager-plugin) – Thomas Bouron Mar 31 '14 at 16:36
  • I have the same problem as @Supercelo describes: SDK is installed and (android-18), and yet Android studio complains. I have tried restart, rebuild, sync with gradle... nothing works. – Ted Apr 01 '14 at 21:45
  • same here. I tried with api level 19 and 18 now - same result. Error:Module 'LabsCore': platform 'android-18' not found. – Sven Haiges Apr 02 '14 at 20:31