Android Studio update 0.5.3 - platform 'androi

2020-02-20 06:23发布

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!

12条回答
何必那么认真
2楼-- · 2020-02-20 07:21

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.

查看更多
戒情不戒烟
3楼-- · 2020-02-20 07:22

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

查看更多
再贱就再见
4楼-- · 2020-02-20 07:23

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.

查看更多
Evening l夕情丶
5楼-- · 2020-02-20 07:25

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.

查看更多
狗以群分
6楼-- · 2020-02-20 07:28

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.

查看更多
叼着烟拽天下
7楼-- · 2020-02-20 07:29

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.

查看更多
登录 后发表回答