Android Hello-World 编译错误: Intellij 无法找到 aapt

我正在尝试在 Ubuntu 12.04中使用 IntelliJ 建立一个 Android 开发环境。我创建了一个 Android 应用程序模块,但是当我尝试构建时,我得到了以下错误:

不能运行程序“/home/jon/Programs/android-sdk-linux/Platform-tools/aapt”: java.io.IOException: error = 2,没有这样的文件或目录

几个小时的互联网搜索没有帮助。

顺便说一下,我在终端运行 locate aapt,发现 aapt位于 /home/jon/Programs/android-sdk-linux/build-tools/17.0.0/aapt

49639 次浏览

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

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.

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

I reckon more votes will be a faster fix.

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.

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 !

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

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

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

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

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

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

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

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