Android Studio: “Please select Android SDK”

2019-01-03 03:49发布

After a successful import of an Eclipse-Android-Project into "Android Studio 1.4" I get the error "Please select Android SDK" when I click on the button to run the application in simulator.

But I can't find any way of doing that.

This dialog opens up when i click on "run":

This dialog opens up when I click on "run"

This is the "project structure" dialog:

Screenshot of the "project structure" dialog

What should I do now?

30条回答
贪生不怕死
2楼-- · 2019-01-03 04:07

enter image description here

Go to File >> ProjectStructure(⌘;). This would open this window then select the app module. Then choose the Compile SDK version . Choose the latest one and click apply.

查看更多
Melony?
3楼-- · 2019-01-03 04:09

I go to build.gradle and click sync now. Then it worked.

Update :

File -> Sync Project with Gradle Files (Android Studio 3.1.1)

Tools -> Android -> Sync Project with Gradle Files (Android Studio 3.0.1)

Or You can click on the icon from the toolbar.

Sync Project Icon

This answer may not help works for later version as Android studio Team work on making the tool more better, the way to sync may be different in the next version of Android Studio.

COMMON WAY that may helps is try to sync project and then Invalidate Caches and Restart Android Studio.

Solution for Android Studio 3.1.2 [See below answer]

See Latest Android Studio version

查看更多
ら.Afraid
4楼-- · 2019-01-03 04:10

Just go to the (app level) build.gradle file, give an empty space somewhere and click on sync, once gradle shows sync complete then the Error will be gone

查看更多
聊天终结者
5楼-- · 2019-01-03 04:10

In my case there there is no selected java sdk version in project structure-

I had to select the -

1.Source Compatibility (1.7)

2.Target Compatibility (1.7)

as shown in image.

enter image description here

查看更多
Bombasti
6楼-- · 2019-01-03 04:11

My problem was that if I changed the project (for example opened new window of Android Studio with different project) this error happened.

So I read every answer in this question and the "clear caches and open the project again" solution wasn't so useful in my case.

Instead I discovered that if the Kotlin's plugin's version in Android Studio was lower than in gradle file, the problem appeared.

My setup was:

  • Android Studio 3.1.3
  • Kotlin plugin (in Android Studio) 1.2.30
  • Kotlin version in gradle file 1.2.51

What fixed the problem?

I updated the Kotlin plugin:

File -> Settings -> Plugins -> Install JetBrains plugin...

Then search for Kotlin and click Update. After update just restart the Android Studio and sync Gradle.

查看更多
我命由我不由天
7楼-- · 2019-01-03 04:12

In my case I downloaded a git repository for an android project. The project required minimum sdk version 21 and target sdk version 27. When I tried to run the project it gave me "Please select Android SDK error". I checked that I had already downloaded the required sdk files.

For me the solution was to "sync project with Gradle Files" enter image description here

查看更多
登录 后发表回答