Android IDE (AIDE) Support Forum

Error "aapt exited with code139" and "unknown entity R"

When I create a new project, I get the error “aapt exited with code139” and “unknown entity R”. What does it look like R.java is not automatically generated, what should I do?
The model is XPERIA Z1.

Again, this is not a error with your project and yes with AAPT , the most common cause is a file in res that was not registered by your R.java .

Try:

Delete bin and gen folder;
Refresh Build;
Restart AIDE (optional);
Build & Run;

In some cases it’s just a simple error that can be solved by just Build and Run (ignorate the error).

Please don’t SPAM

I tried, but R.java was not generated.
If you delete the gen, bin folder and build & run, only BuildConfig.java is generated without generating R.java in the gen folder.
It will look like this when you first install AIDE, what should I do?

It looks like you have changed the package of your app

If you are using gradle remember to change the package of build.gradle and AndroidManifest.xml!
If the R.java is not generated probably its build.gradle

I don’t know what that means. Could you tell me more if possible? Please.

I got this error before. It’s tricky. Sometime, you need to backup the work, Delete all files of your project and recreate the project then copy necessary work (Activity, Manifest, some rest).
This error happen usually when delete some files in build folder (even delete all build, can cause the error), AIDE corrupt when rotate screen while compiling, corrupt by command from other app (os app).
To avoid this error, I use Kill App on Google Play to turn off AIDE completely before each time compiling. And NEVER rotate device while compiling. (Fragile. Lol :joy_cat:)

1 Like

Well I have the same problem after a reinstall. And what people say here doesn’t help me understand how to fix it. Tutorials don’t work either. They keep throwing errors but no red lines to point to them. Until yesterday it worked fine.

It’s not a user’s coding error. It’s a conflict inside AIDE engine, when rewrite data in build folder while compiling.
All I can do if got this error is delete build folder, using Kill App to kill all service AIDE, then open the AIDE and refresh build. If still got error: backup coded file -> Delete All project’s folders -> Create new project -> past the backup coded file and resources.