3

Today I've installed Android Studio Canary 1

Now I cannot run my app. This following dialog appears.

I've already set the right SDK location through File-> Project Structure-> Android SDK location.

Expecting your help to solve this problem.

Warning Dialog image:

enter image description here

Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52
Febin K R
  • 886
  • 2
  • 11
  • 21

10 Answers10

7

Go to project structure settings and set Source Compatibility and Target Compatibility to your current java development kit version:

List item

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Vincent Mungai
  • 202
  • 3
  • 4
5

Just you need to sync your project file with your gradle file.

File -> Sync Project with Gradle Files
Alireza Noorali
  • 3,129
  • 2
  • 33
  • 80
4

I tried every answer in this post but my problem only got resolved when I made these steps:

File -> Close project -> Remove project -> Open existing project (same project)

Maybe this will save a morning to another person with the same bug.

EDIT

This happened to me a lot on a MacBook. After I posted this answer it just kept happening so what I did was:

  • uninstall the Android Studio version I had from the App Store;
  • download the desktop stable version from Android Studio website;
  • start using the desktop version of Android Studio.

Never happened again.

luiscosta
  • 855
  • 1
  • 10
  • 16
  • But unfortunately, the error repeatedly occurred again and again after some time. I removed all the dependencies of Kotlin from the gradle files and that permanently fixed the problem for me now. – Febin K R Nov 19 '18 at 05:54
  • @FebinKR I just edited my answer for people to whom it keeps happening. – luiscosta Nov 21 '18 at 10:55
3

Sometimes the SDK path will be incorrectly configured. You would need to fix it.

  1. To Settings/Preferences( command + , on mac).
  2. Search for SDK
  3. Under Android SDK, click on edit and point it the root of sdk directory on your file system. (If ther is no SDk installed then install in from the below list).

    enter image description here

Build3r
  • 1,748
  • 16
  • 22
1

i suggest you go to build.gradle and sync again. Or Tools -> Android -> Sync Project with Gradle Files (Android 3+)

Bilal Shahid
  • 490
  • 9
  • 16
1

You need to insall SDK api 19 check this out. https://developer.android.com/studio/releases/platforms

Crisgon
  • 11
  • 2
  • I don't think it's correct, check your answer – Gonçalo Garrido Feb 18 '22 at 10:50
  • 1
    works for me instal that version – Crisgon Feb 18 '22 at 10:53
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 18 '22 at 14:11
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31102164) – Abhishek Dutt Feb 25 '22 at 05:33
0

Go to sdk manager and install sdk according to your device and check your device api. Example if your device is jellybean then install api 19 sdk.

Majid Ali
  • 485
  • 6
  • 17
0

Go to Tools> Android > SDK Manager and make sure you have selected default Setting under System Setting. In this image I have selected Android 7.1.1 as default SDK

enter image description here

Ajay B
  • 746
  • 9
  • 19
0

I had the same problem and what it worked for me was just sync with gradle. I just did what I've found in this similar question:

How do I "select Android SDK" in Android Studio?

The original answer:

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

Before that, by the way, I had invalidated cache and restarted too, but it didn't work. Please, try and let us know.

P.S. I had this problem after I imported a project from Git, just in case someone would like to replicate.

EmmettBrown88
  • 148
  • 1
  • 2
  • 13
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/20349223) – Busti Jul 19 '18 at 16:16
  • Thank you for your suggestion, but it is just that. It is just "sync with gradle". I don't know what else to inlude :) – EmmettBrown88 Jul 19 '18 at 17:08
  • @Busti Ok, now I got it. Original naswer included. – EmmettBrown88 Jul 19 '18 at 17:19
0

enter image description here

Just click on the button ..."Sync Project with gradle file" Error will be remove

Machavity
  • 30,841
  • 27
  • 92
  • 100
Tanveer
  • 41
  • 2