How to diagnose "Error executing aapt" error in Eclipse? - android

I'm ready to tear my hair out because I can't get Eclipse unstuck from a state where it thinks it can't find aapt:
Error executing aapt. Please check aapt is present at /usr/local/android-sdk-linux_x86/platform-tools/aapt
I've found a bunch of posts on this subject, which suggest deleting the error in the Eclipse UI, deleting R.java, rebuilding the project, restarting Eclipse, etc. These things help temporarily, but as soon as I edit an XML file, Eclipse gets borked again. It's getting really annoying to rebuild all my source and restart Eclipse every time I change an XML file.
aapt is clearly there:
$ ls -l /usr/local/android-sdk-linux_x86/platform-tools/aapt
-rwxr-xr-x 1 boris boris 3764858 2011-07-28 11:50 /usr/local/android-sdk-linux_x86/platform-tools/aapt
Is there a way to know exactly what the error is that's occurring? I tried looking in the Eclipse console output and in .metadata/.log in my project and didn't see anything related.

Hit this again today, and discovered that verbose output from aapt doesn't help. It just spits out the aapt command to the console and fails without an error.
I think I've finally gotten to the bottom of what's going wrong. I believe that aapt is failing due to insufficient memory. My Eclipse process was using 1.2GB of memory. When Eclipse runs aapt, it forks the process which, from what I understand, allocates another 1.2GB just for running aapt.
I looked at my process list, and saw that Firefox was using almost 400MB of memory. I killed Firefox, and then aapt started working. Crazy.

Finally found the answer to my question here:
http://groups.google.com/group/android-developers/browse_thread/thread/bad9d488d2068260
Turns out that you can see the aapt command and output by setting "Build output" to "Verbose" in Preferences/Android/Build. Weird that they don't spit out the output when an error occurs.

In my case (fresh Eclipse installation, new project generated with wizard, errors like "Couldn't resolve R to variable") the problem turned out to be with absense of trailing slash in path to Android SDK at Preferences->Android.

Hint (suggested by Eclipse on Ubuntu): On 64-bit systems, make sure the 32-bit libraries are installed: sudo apt-get install ia32-libs
That has solved my problem !

I had this because of a misdeclared ID in one of the resources files. I'm using Android Studio (but not gradle), and I had in a style declaration a reference to an #+id/... which isn't allowed, apparently. I had to declare the ID in another values xml files as <item type="id" name="..." />.

This error can be caused by an invalid drawable id, such as
android:icon="#drawable/ic_action_search_whatever"
If there is no drawable called ic_action_search_whatever aapt will die. Simple error, but not an easy one to debug!

In my case, the "Android SDK Build Tools" (version 20.0) was broken somehow. So I updated the tool to the latest one(21.1) using the "Android SDK Manager" & voila - it got OK :).

Aapt is a 32bit application. I am running ubuntu 64bit. I needed some additional libraries.
To get aapt working (this fixed my issues with the avd as well) just run these two commands:
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1
Enjoy

I actually noticed that I had converted my jpg file to png file that's why the aapt error was coming.

Related

IntelliJ: project not generated with android tool - permission denied

I'm at a bit of a loss with this one, I'm sure it's a pretty simple problem really.
It has located the SDK and I have already installed the required build tools etc. For some reason it doesn't have permission to access the files.
I'm using ubuntu and the SDK is installed in /usr/local/android/android-sdk-linux/ . Is this as simple a problem as me placing the SDK in a bad location?
EDIT: I have fixed the issue by using the following in the command line:
chmod a+x .../tools/android
However, I'd like to know if I've removed all issues I might face in the future, and how I should actually correct this.
In case anyone else stumbles across this:
I have fixed the issue by using the following in the command line:
chmod a+x .../tools/android
Thus allowing access to the android function in the tools directory. Everything seems to be working fine now.

Error when trying to run Cocos2d-JS project on Android

The error I get is in this part:
running: '"C:\apache-ant-1.9.4\bin\ant" clean debug -f C:\Users\Robert\Desktop\N
ormero\Games\Aztec\frameworks\runtime-src\proj.android\build.xml -Dsdk.dir="C:\a
ndroid-sdk"'
The filename, directory name, or volume label syntax is incorrect.
Error running command, return code: 1
I'm running:
cocos run -p android
On windows 7 64bit. I have googled but I'm stumped. Also I'm not a genius in Java nor Android, hence I use Cocos JS.
EDIT: Someone pointed out to me that the dot (.) in proj.android might be causing the issue. Any way I can fix this easily?
EDIT2: It happens during the compile, but the weird thing is, I can execute the command it says it errors on, and then it goes BUILD SUCCESFUL.
Your python version is not suitable. reinstall python 2.7.5
and it will be work =)
I faced the exact same issue then searched and found that "The filename, directory name, or volume label syntax is incorrect" error message is probably related to Python.
The filename, directory name, or volume label syntax is incorrect
I have both Python 2 and 3 in my machine but my PATH is pointing to 2.7.0 due to failsafe setup for some node.js projects. Then I reviewed the release note of Python 2.7 below:
https://hg.python.org/cpython/raw-file/v2.7.12/Misc/NEWS
And found there are numerous issues are associated with path. Without touching cocos2d first, I decided to remove 2.7.0 and installed 2.7.8. (just an old binary)
The propblem was solved immediately.
(Thanks justderb to remind and more details are provided.)

How to fix Android Studio getting stuck executing Gradle tasks?

Android Studio (Beta) 0.8.6 gets stuck when I try to build/run the project, as well as clean it. It stays responsive, but the Gradle: Executing Tasks message doesn't disappear (longer than 20 minutes is when I give up) and the app never runs.
This is what I attempted:
Invalidate caches/restart
Force quit and restart
Remove it from Applications (on Mac) and re-download it from the official website.
Fixed it by going to Android Studio -> Preferences -> Gradle -> and ticking Offline work. Still have no idea what was wrong, but at least now it compiles.
Edit:
In new Android Studio Versions the path is File -> Other Settings -> Default Settings -> Build-Excecution-Deployment -> Gradle
The question seems old but in case anyone need it.
I have just faced this problem recently, after a fresh Ubuntu 14.04 installation.
After google for a while with no luck i checked the terminal, it turned out that libz.so.1 is missing. So i installed it, worked like charm.
Installing instruction here:
libz.so.1: cannot open shared object file
Enable Offline Work from Setting
This can happen for lots of reasons. So instead of giving an exact fix, here are some steps to help isolate the cause.
Run the gradle command from command line. Does it still fail?
$ ./gradlew myTask
If so, re-run with debug flag. Any useful info?
$ ./gradlew myTask --debug
If it's just hanging, try getting a stack trace. Search the dump file for myTask
$ jps -mv | grep Gradle <--- be sure to use capital "G"
2290 GradleDaemon 3.3 -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xmx2304M -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
$ jstack -l 2290 >> dump.txt <--- your process ID will be different
If it's only hanging when running Android Studio, generate thread dump for Android Studio read more here.
You have to add execution mode to the file: AndroidStudioProjects/YourProjectName/gradlew so that Android Studio can execute it.
if you are on a linux machine use this command: chmod +x gradlew
to run this command you may need to have administration privileges. in Ubuntu you can use sudo chmod +x gradlew to do that
In my case looks like gradle was missing 32 bit library on a 64 bit Ubuntu 16.04. Doing sudo apt-get install libstdc++6:i386 resolved the problem.
This happened to me after adding google play api to dependencies{}. ./gradlew app:assembleDebug showed an error saying something like Dex ID limit reached use multi-dex. just as I was setting it up as described here, I decided to remove the dependency I recently added and the issue was gone.
Google also suggests using proguard as a technique to optimize the number of Dex IDs in the same document.
For GNU/Linux Users:
I copied the SDK from another storage to my home directory. Then I was getting stock gradle build running. The problem was the permissions of SDK files. Watch the gradle console log and if you see some permission denieded stuff, then do the following - give all the files executing permission by this command:
chmod -R +x /path/to/android-sdk
After a lot of struggle and following all solutions posted above (and in similar posts) I finally found that the problem on my PC was the antivirus application. I disabled it and gradle refreshed and built fast, as it did before the problem started.
It looks like my antivirus recently started blocking gradle from updating/downloading necessary information from the Internet and that is what is causing the delays and eventually timeouts in loading and refreshing a project. Disabling the antivirus it corrects the problem, every time.
I have centos 7 64 bits installed on a virtualbox 5.0.16 virtual machine and gradle version 2.10 with Android Studio 2.0
The log file of gradle is located at $HOME/.gradle/daemon/2.10
Log file: daemon-<some number>.out.log
By inspecting this log file I found out that libz.so.1 was not found by aapt.
Despite that command "locate libz.so.1" output was
/usr/lib64/libz.so
/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.7
aapt was not able to find it.
In order to solve the issue I had to execute
yum install zlib.i686
After that Gradle started working as a charm.
Good luck!
I had something similar.
When I ran gradle from the command like it would throw this exception
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDevDebugJavaWithJavac'.
after waiting at this line for like 25 minutes
:app:compileDevDebugJavaWithJavac
it turned out to have something to do with the android annotations I was using. I replaced the
#UiThread
I was using with
activity.runOnUiThread(new Runnable(...
And it started to compile just fine. Its weird because I was using the #UiThread annotation in lots of other places in my code.
In my case, I was getting this error by the Gradle Builder (Android Studio 2.2, Windows 10)
java.lang.RuntimeException: Timed out while waiting for slave aapt process, try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
The solution was just to add the variable SLAVE_AAPT_TIMEOUT to my Windows environment, and set it to 30
I was with the same problem and solved setting variable SLAVE_AAPT_TIMEOUT in System Variables with the value 30.
I'm on Windows, and I had the same problem.
For me, the gradlew executable somehow got deleted, no idea how. I'm on the Canary, and I've had the issue before.
In the terminal window on Android Studio, type gradlew and it will redownload and install it if it's missing. (My old solution was a complete reinstall of Android Studio, so this is easier)
I had the same problem, even with new standard projects (Ubuntu 16.04). The problem turned out to be in third-party dependencies of the Gradle. View the file:
~/.gradle/init.gradle
It may contain additional dependencies, which the Gradle can not load.
You can see what can not be loaded in the console:
./gradlew --debug
If you use realm library and use RealmStudio or RealmBrowser to open file .realm, make sure you perform delete file .realm/lock and folder .realm.management.
I think java.exe is the reason of this issue. Just manually kill this application and try. It really worked for me using Android studio 3.0.1.
In my case it was stuck on mergeDebugResources because I accidentally had a double-escaped single-quote \\' in a string. Android Studio doesn't mark this as an error, but instead gets stuck building!

Configuring Android to use in terminal for Linux Mint

I am currently using Eclipse to develop Android apps. Following the Android Developer tutorial, they had the option to program using the command line. I am interested in doing it this way but ran into a number of errors. I have tried several solutions available on the internet and I fear that I might have added to many things on my PATH file. None of the solutions have worked for me.
I am very lost with all these directories. Please help for Linux Mint specific distribution.
Key errors to address are:
android: command not found
and
ant debug
Buildfile: build.xml does not exist!
Build failed
I downloaded adt-bundle-linux-x86-20130717.
Update:
I think I managed to get the android command working by hardcoding the following on my bash.bashrc:
/etc/.../sdk/tools
/etc/.../sdk/platform-tools
Please let me know if it is recommended to do this another way.
However, ant debug is still not working.
If ADB is properly in your path, the android command should launch the SDK updater. Here is what I have in my .bashrc
# SDK
PATH=${PATH}:~/android-sdk/tools
PATH=${PATH}:~/android-sdk/platform-tools
You put the environment variable configuration in which files? configuration is completed, use the source command to run the file, or try to restart the computer

I keep getting a "[...]/bin/*-ar: not found" error while building the V8 javascript engine for Android

I'm trying to build the V8 javascript engine for Android but I can't succeed for some reason. I follow the instructions given here. It all starts very well. I can issue the make android_arm.release -j8 command from my terminal and it seems very sweet for a while. Then suddenly I get this output:
/bin/sh: 1: /home/dbm/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/*-ar: not found
The statement is correct: there is no *-ar file at the specified location.
But what is an *-ar file? And how can I resolve this error?
The environment is a beast running Ubuntu 12.10 on a 64-bit architecture (with ia32-libs installed) and I build for/with/against Android NDK r8c.
There seems to be a problem in Ubuntu!?
Anyway - extracting via tar -jxf worked for me. See http://code.google.com/p/android/issues/detail?id=41187
The issue lies with the fact that the NDK build system prefixes the platform name to the commands that are run to build the source. If you notice the error you get, the correct platform prefix is missing from *-ar. Somehow, the platform name is being set to * instead of the correct prefix arm-linux-androideabi (giving the correct name arm-linux-androideabi-ar). You'll need to figure out where this information is being skipped. That should fix your problem.
PS. If I get some free time, I'll try and replicate your issue and see if I can give you the exact fix.
Use the 'tar -jxf' to extract the android ndk. If you use the 'Extract here' option, it seems to be leaving out some files.
ar is archive utility from gnu tools. Normally you should have a $NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-ar available in your tool chain. which looks like missing in yours.

Categories

Resources