在成功地将Eclipse-Android-Project导入到“Android Studio 1.4”后,我得到了错误
"Please select Android SDK"
当我点击按钮在模拟器中运行应用程序时,我找不到任何方法来这样做。
当我点击“run”时,这个对话框就会打开:
这是“项目结构”对话框:
我现在该怎么办?
在成功地将Eclipse-Android-Project导入到“Android Studio 1.4”后,我得到了错误
"Please select Android SDK"
当我点击按钮在模拟器中运行应用程序时,我找不到任何方法来这样做。
当我点击“run”时,这个对话框就会打开:
这是“项目结构”对话框:
我现在该怎么办?
当前回答
我的问题是,如果我改变了项目(例如用不同的项目打开Android Studio的新窗口),就会发生这种错误。
所以我阅读了这个问题的每个答案,“清除缓存并重新打开项目”的解决方案在我的情况下并不是那么有用。
相反,我发现如果Kotlin插件在Android Studio中的版本低于gradle文件中的版本,问题就会出现。
我的设置是:
Android Studio 3.1.3 Kotlin插件(在Android Studio) 1.2.30 Kotlin版本在gradle文件1.2.51
是什么解决了这个问题?
我更新了Kotlin插件:
文件->设置->插件->安装JetBrains插件…
然后搜索Kotlin并单击Update。更新后只需重新启动Android Studio和同步Gradle。
其他回答
在本地给出SDK路径。属性文件为
sdk.dir=C\:\\Users\\System43\\AppData\\Local\\Android\\sdk
并在gradle文件中给出compilesdk的最新版本。
After opening my project in Android Studio, I opened the App version of the build.gradle file, located in the Gradle Scripts folder of the Project. When I hovered my mouse pointer over the buildToolsVersion number, a tooltip popped, indicating that the version of Android Build Tools needed to be upgraded (see screenshot). I changed the value of the buildToolsVersion to the one identified by the error (27.0.2) and the problem was solved. The original error (Please select Android SDK) went away and the project compiled successfully, again. Although this solution was mentioned previously, the exact steps seemed to be missing, so hopefully this clears up any doubt. I guess the root cause for this problem is that a new version of the build tools were released but Android Studio did not trigger any notification to me, which would have indicated that I should manually fix this (since Android Studio does not seeem to have the ability to upgrade this build.gradle file internally), which leaves the onus on the user to find the problem and fix it.
修复了3.1.2或更新版本
我和我的一些同事在AS 3.1.2上也遇到过同样的问题,但是一个简单的同步并没有帮助我们。对我们来说,解决方案有点不同:
File -> Invalidate cache -> Invalidate File ->关闭项目。 从AS项目选择器窗口中删除该项目。 退出Android Studio 启动AS并再次打开项目
如果你经常面临这个问题,额外的建议
你们中的一些人经常面临这个问题,而这个“解决方案”只能暂时解决它。在我们开始出现这个错误的时候,我们使用gradle包装器4.6和Android gradle插件3.1.0,但从那以后我们回到gradle 4.4,我们使用了最新的Android gradle插件,从那以后我们就没有看到这个问题了。
该项目依赖于SDK,但没有SDK。 进入文件->项目结构(编辑:我说设置之前) 选择Modules,然后转到Dependencies选项卡 您可能会在Export列中看到No SDK。 从Module SDK下拉菜单中选择一个,如果列表为空,则创建一个新的。 没有SDK现在应该更新到选定的SDK。 那么它应该能起作用……希望。:) 问候
在最新的android studio 3.3.2中,Gradle文件同步项目的图标发生了变化
现在试试这个
文件->同步项目与Gradle文件(Android Studio 3.3.2)