简体   繁体   中英

IntelliJ IDEA unable to find android sdk

I'm trying to import a libGDX project into IntelliJ running OSX 10.9. When creating my own project it's not an issue specifying the path to the android sdk in the gdx-setup, but when importing one I keep getting the issue:

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

截图

I haven't found anything resembling a local.properties file and wouldn't know how to create one, so I set the ANDROID_HOME environment variable with the path to my android sdk, adding this to my .bash_profile: export ANDROID_HOME=/Applications/android-sdk Additionally I added $ANDROID_HOME:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools to my PATH as well, which seems somewhat overkill, but unfortunately the PATH isn't recursive .

IntelliJ isn't getting any of this however, I'm guessing adding it to my .bash_profile isn't the right way of doing it?

Thank you very much in advance!

So thanks to the friendly people in the libGDX IRC it turned out to be relatively easy adding the local.properties file. The necessary content is just

sdk.dir=/path/to/android/sdk

This solves the problem and IntelliJ is now able to import the project. No further info on using environment variables.

This is unorthodox but I cannot comment(not enough karma) so I'm writing an answer instead, where is the local.properties file that you speak of? I am unable to find it.

However I've solved it by:

  • open your Project Structure settings (Ctrl+alt+shift+s)
  • Under the Platform Settings group select SDKs
  • with the + sign add Android SDK > Select your /path/to/android/sdk
  • Select build target
    • Optional : I've also named the sdk as 'android' I am unsure whether this fixed anything but it does make sdk's ambiguous
  • Apply
  • Go to Project Settings and choose Modules
  • Select android and under Module Sdk choose the android sdk we just added (renaming can come in handy here).
  • Apply, wait and done.

On IntelliJ IDEA 2016.1.2 it's worked this way for me:

  • Menu File -> Other Settings -> Default Project Structure...
  • There on the left under Project Settings -> Projects
  • Click on New... button
  • Choose Android SDK and insert path to it.

After that for you new or imported projects IDEA will know where to find Android SDK

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM