Android Hello-World compile error: Intellij cannot find aapt

假装没事ソ 提交于 2019-11-26 15:22:53

问题


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


回答1:


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.




回答2:


update your IntelliJ to 12.1.4 by using beta releases as the update channel




回答3:


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




回答4:


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




回答5:


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



回答6:


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




回答7:


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

I reckon more votes will be a faster fix.




回答8:


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




回答9:


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.




回答10:


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 !




回答11:


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




回答12:


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



回答13:


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



来源:https://stackoverflow.com/questions/16588969/android-hello-world-compile-error-intellij-cannot-find-aapt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!