90

I'm trying to get set up with an Android development environment using IntelliJ in Ubuntu 12.04. I create an Android Application Module, but when I try to build, I get the following error:

android-apt-compiler: Cannot run program "/home/jon/Programs/android-sdk-linux/platform-tools/aapt": java.io.IOException: error=2, No such file or directory

Several hours of scouring the internet hasn't helped.

By the way, I ran locate aapt in the terminal and found that aapt is located at /home/jon/Programs/android-sdk-linux/build-tools/17.0.0/aapt

jonS90
  • 1,369
  • 2
  • 11
  • 15
  • Well, thanks for all the answers guys! I switched to the [Android Studio](http://developer.android.com/sdk/installing/studio.html) fork, and it's working just fine. But I think the other solutions regarding symlinks or the android-maven-plugin may be more appropriate for other intellij users. I suppose this will be fixed in an update in a matter of time... – jonS90 May 17 '13 at 17:28

13 Answers13

130

It appears that the latest update to the r22 SDK release moved aapt and the lib jar from the platform-tools to the build-tools directory. While we wait for JetBrains to release an update, here's a quick fix using a couple of symbolic links:

From your AndroidSDK/platform-tools directory, run the following:

ln -s ../build-tools/17.0.0/aapt aapt
ln -s ../build-tools/17.0.0/lib lib

...and IntelliJ should be able to compile as normal.

Simon Guest
  • 2,112
  • 1
  • 15
  • 21
  • 21
    Hi, perfect for me too. Just for info: I run Intellij under Windows, you can open a DOS prompt with admin privileges, and run: `mklink D:\Android\android-sdk\platform-tools\aapt.exe D:\Android\android-sdk\build-tools\17.0.0\aapt.exe` and `mklink /D D:\Android\android-sdk\platform-tools\lib D:\Android\android-sdk\build-tools\17.0.0\lib` – Francesco Pez May 20 '13 at 15:24
  • Also had to add: `ln -s ../build-tools/17.0.0/aidl aidl` – xaviert May 29 '13 at 10:37
  • 3
    If you're getting this and executing aapt directly also says file not found, you may be having a 64-bit issue: [link](http://stackoverflow.com/questions/8328250/centos-64-bit-bad-elf-interpreter) – Tomas Jun 02 '13 at 07:07
  • @FrancescoPez Doesn't work in XP or in systems using fat32. For WinXP: http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html – Yet Another User Aug 10 '13 at 02:05
  • For Windows 64Bit users like Francesco Pez mentioned just the hint for paths with spaces: put both paths in quotation marks e.g. mklink "C:\Program Files\androidsdk\sdk\platform-tools\aapt.exe" "C:\Program Files\androidsdk\sdk\build-tools\android-4.3\aapt.exe" – syr Oct 09 '13 at 22:58
21

update your IntelliJ to 12.1.4 by using beta releases as the update channel enter image description here

JoachimR
  • 5,150
  • 7
  • 45
  • 50
  • 2
    This did it, however, I had to select EARLY RELEASES, that showed the .4 update then when it restarted I got the 3.x which i denied. (Mac OS X 10.8.x) – Martin Marconcini May 28 '13 at 18:07
12

In Windows it is enough to copy only aapt.exe, lib\dx.jar and dx.bat

from build-tools\android-4.2.2

to

platform-tools

radistao
  • 14,889
  • 11
  • 66
  • 92
10

The same problem occurred for me with android-studio. But, this probably applies to the IntelliJ IDE as well.

When checking the file location I saw, however, that aapt was in the expected location.

In my case the issue was that I was running a 64-bit Ubuntu linux system which cannot execute the 32-bit aapt executable.

Installing 32-bit compatibility libraries solved this issue in my case: sudo apt-get install ia32-libs

  • It seems `ia32-libs` is no longer available for Ubuntu 13.10 and up. – Chad Bingham Mar 28 '14 at 19:54
  • Add `deb http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse` to `/etc/sources.list`, then `sudo apt-get update` and then `sudo apt-get install ia32-libs` – Mendhak Apr 09 '14 at 23:07
6

i solve it with this to line commands

ln -s ~/Programs/android-sdk-linux/build-tools/17.0.0/aapt ~/Programs/android-sdk-linux/platform-tools/aapt
ln -s ~/Programs/android-sdk-linux/build-tools/17.0.0/lib ~/Programs/android-sdk-linux/platform-tools/lib
taha
  • 731
  • 2
  • 7
  • 18
3

I also noticed it.

ADT has been updated and they added this new build-tools where they moved everything. Intellijidea is not updating paths so it's searching aapt in the old path.

I don't know how to solve it, so let me know if you find a solution...

UPDATE:

I think that you have only 2 options:

1) Use Android Build studio: http://developer.android.com/sdk/installing/studio.html 2) Copy (this is dirty but works) all content from build-tools/17.0.0/ to platform-tools/ and it will build

StErMi
  • 5,389
  • 5
  • 48
  • 71
  • Ah, an update issue. Ok, so I just found that Google released [Android Studio](http://developer.android.com/sdk/installing/studio.html), which is a _fork_ of Intellij. Maybe Google expects people switch to [Android](http://developer.android.com/sdk/installing/studio.html) Studio rather than update Intellij? – jonS90 May 16 '13 at 13:48
  • Yes they releaed it (take a look at yesterday Google I/O keynote). It's basically JideaCommunity + more focus on android. Then it will be merged with JideaPro (I hope so). – StErMi May 16 '13 at 13:54
  • 2
    It's not really a fork, it is based on the Early Access Program build. Once that EAP build becomes mainline IntelliJ it will have the same features Android Studio has. – powerj1984 May 18 '13 at 14:49
2

To complain to Jetbrains, go here: http://youtrack.jetbrains.com/issue/IDEA-107311

I reckon more votes will be a faster fix.

xorgate
  • 2,244
  • 1
  • 24
  • 36
2

Thanks for the tip! On a mac running the Android 4.2.2 SDK, this worked great. You'll just need to update your paths accordingly. E.g.

ln -s ../build-tools/android-4.2.2/lib lib

ln -s ../build-tools/android-4.2.2/aapt aapt

martenc
  • 668
  • 6
  • 7
1

I ran into this issue but with android-maven-plugin and as a variant of your item #2 rather than copying the file(s) I simply created a symbolic/soft link for aapt

cd platform-tools
ln -s ../build-tools/17.0.0/aapt ./

This approach seemed to get all my builds functioning again.

Don H.
  • 44
  • 1
  • 5
1

Clone the android-maven-plugin on GitHub and install it in your repo

git clone https://github.com/jayway/maven-android-plugin.git
cd .../maven-android-plugin/
mvn clean install

Then update your pom to use version 3.5.4-SNAPSHOT of the plugin. Everything should work properly !

avianey
  • 5,545
  • 3
  • 37
  • 60
  • Note, however, that this will fix the maven build, but not the IntelliJ build. For that, the symbolic link workaround should help until IntelliJ fixes it. – Andy Dennie May 17 '13 at 15:37
  • you should be able to find the android-maven-plugin version somewhere in the IntelliJ conf... – avianey May 17 '13 at 18:50
  • the built-in IntelliJ build system doesn't use android-maven-plugin. To make it work, you'd need to do the symbolic links. And if you do the symbolic links, you shouldn't need to update to the latest snapshot of android-maven-plugin; the links will fix both the IntelliJ build and the non-latest version of android-maven-plugin. – Andy Dennie May 17 '13 at 20:34
  • Yes, I have a windows environment. Start a DOS window as administrator, then use the mklink command. Go to platform-tools, then create links for aapt.exe, aidl.exe, dexdump.exe, dx.bat, and lib\dx.jar to their counterparts in build-tools\17.0.0 and build-tools\17.0.0\lib. Note: you'll need to create the lib subfolder under platform-tools. – Andy Dennie May 18 '13 at 14:49
0

I ran these three commands and my problem was resolved

mklink "%ANDROID_HOME%\platform-tools\aapt.exe" "%ANDROID_HOME%\build-tools\17.0.0\aapt.exe"

mklink /D "%ANDROID_HOME%\platform-tools\lib" "%ANDROID_HOME%\build-tools\17.0.0\lib"

mklink "%ANDROID_HOME%\platforms\android-17\tools" "%ANDROID_HOME%\build-tools\17.0.0\aidl.exe"

If you haven't set ANDROID_HOME Environmental variable the replace %ANDROID_HOME% with the path to your android SDK e.g. C:\Android\android-sdk

Raheel
  • 4,953
  • 4
  • 34
  • 40
0

On Mac OS you need to

$ cd platform-tools
$ ln -s ../build-tools/android-4.2.2/aapt aapt
$ ln -s ../build-tools/android-4.2.2/lib lib
Alexander Volkov
  • 7,904
  • 1
  • 47
  • 44
0

Goodlife once again. Just incase of such an error clean project and you are good to go.

Goodlife
  • 3,822
  • 2
  • 24
  • 23