How Solve and Prevent Aapt_rules.txt Not Found Error on your Android Studio App Development.

Hello, My name is Mark John.. 
I am 18 years old. I am an Android Developer.

There is nothing Painful in software development than to get an Error when building that software.
First, you will be confused. Second, you will be frustrated, Third, you will be tired. All this because you saw your long hour stress been mocked by that stupid Error Inspector in the IDE.

In today's Article I will be sharing with you my Experience with this particular error called Aapt_rules.txt Not Found Error. Although I have seen worst error that it that have almost driven me Crazy, but I survived.

I will start first be showing you how to solve it, because the only reason why you will look for Articles like this is because you have a problem like this.

Note this Article might be Long so, sit back and read along.

Now let start....

HOW TO SOLVE THE AAPT_RULES.TXT NOT FOUND ERROR.

When you get errors like this do not panic the cause is that a particular file called the Proguard rule is missing from your Andriod App build folder, and there are couple of things that can cause this to happen. Some of those things are;

* Your Gradle not building properly
* Release tab Minify features in your Project Structure is not Enabled.  or the Minify was not enabled when your initially build Gradle in release mode. (More of this will be explained below)

This things above are some of the things that can cause this errors, now to solve it.

Note that there are many ways to solve this error, but in this Article I will share with you the one that worked for me.

Steps to solve this Error:

1. Go to Folder of the current App you are building and find the build folder. below is my own App build folder directory

C:\Users\Mactrix\PaperWall\app\build

Locate this folder and move it away from there and paste it in any place outside the Apps folder in my case PaperWall folder.

2. Go back to your Android Studio IDE and go to the Build Tab at the top of the IDE.
Clicking on it you will see the Option to re-Build. Click on this Menu Option.

Now I know you might be scared that you laterally remove a folder from your app Project folder. This should not scare you because it is for the better. 

Now what the re-Building does is that it will recreate another build folder in for that your app and the good thing is that this time it will have the Proguard rule which was missing from the last build folder. If you are wondering where to find this Proguard rule let me show you mine, this will be a directive to find yours..

C:\Users\Mactrix\PaperWall\app\build\intermediates\proguard-rules\release

At this release folder you will find the aapt_rule. 

Note: Do not be worried with you go to your App project folder and you can not see the Proguard rule folder, it is only Created when you build Gradle in release Mode and your minify is enabled. This two things must be present for the Proguard rule to be created.
This forms the basics for how to prevent this error from happening.

3. The re-Building process takes a lot of time, I do not means One hour or Two, it might that about four, five and so. I actually saw the wicked side of this process, because mine took about 17 hours. Yes it took that long and it did not even finish. I have to stop it myself but I mad sure that the Proguard rule was created. But be make sure that when you are re-Building, you are doing so in release Mode and minify is enabled  unless all you have been doing will be waste.

4. Here comes the reason will I told you to move the former build folder somewhere else and not to Delete it. Re-Building takes a lot of time and all the process is trying to do is to re-create all those files you have before. And remember that you only re-build to get One file, and now you have got it by re-building but other files are yet to be create and you have spent about 10 hours re-Building and you can not wait anymore and you want to do other things because laterally you can not spend two days or so on just re-building.

So to make it easy, after letting it build for some time like 5 hours or so depending on you but still leaving it to keep running and also make sure the Proguard rule folder is created. 

The next things is to get the Old build folder and copy all the things you cannot find in the new build folder but you can find in the old build folder and paste it into the new build folder. Make sure the new build folder has all the things the Old build folder has with the extra things like the newly create Proguard rule.

5. At this point you can now stop the re-Building and immediately switch the build type to debug mode, because the rebuilding occurred in release mode and some debug mode features where not created. Once the Gradle have finish building in the debug mode, go back and make sure the minify is enabled and the Proguard rule folder is there in the App Project folder. After this change build type to release and build Gradle and then carry on with the Generation of APK and you will have a smooth sailing.

Do all this above you will solve the Aapt_rule.txt Not Found Error.

Next..

HOW TO PREVENT AAPT_RULES NOT FOUND ERROR

As the they say, Prevent is better than Cure. Why solve an Error when you can prevent it.

Here I will walk you through the process of preventing this error from happening.

Steps to prevent this Error:

1. When you newly Start a New project or when you are done with it and you want to release it and generate its APK. Then next thing you should do is to go to your App Project Structure Menu at the top of the IDE or through the File menu. Note Make sure that the build type is still at debug Mode, this is because the Error occurs with you build Gradle in release mode and the release mode minify is still at false. After building the system will thimk you are not interested in using Proguard rules for you App project.

When you are in you Project Structure follow this directive to locate your release mode minify

Project Structure>app>release>minify

These above means you should click on Project structure then locate the option named app,click on it then click on the release and at the right side you will see some sitting option, look for minify and set it to TRUE.

Once you set it to true, click OK and let the Gradle build in the debug mode.

2. Once the Gradle has finish building, change the build type to release and also let it build. Make sure that this is the first time Gradle is building in the release Mode. All that I am trying to say is that Gradle should not build in the release Mode if minify is false. Unless the Error will occur and will have to rebuild .

Minify must be TRUE  before you can ever build Gradle in release Mode.

3. After this you can Generate APK or if you have not finished with you App development, just continue with it, you  have not problem from now on.

To Confirm if you are safe, Once you have done this steps above, before Generating APK go to your App Project folder and open the build folder and look for proguard rules folder. If you follow the step correctly you will see the folder there and it will surely have the aapt_rule.txt file in it.

Wow, that was Long. Thank you for Sticking around to the end, I hope this solves your problem and I believe it will because it also solved mine.

If you have any question or something to add to this, something like you own experience with this error and how you solved it, write it in your comment for other to read and learn from it so that they too can Solve theirs.

Thank you very much...

http://bit.ly/Mactrix class='ads'
Superlink


  

Comments