1

I am following "The Big Nerd Ranch's Android Programming Guide" book (2nd edition) and in a particular chapter (chapter 21), they ask you to use a 9-patch image for some image assets. Up until then, the app that I wrote, called BeatBox, worked perfectly fine and compiled without error.

But, when I go ahead and replace some drawables with a 9-patch image, I run into a build error and I just cannot make the app to build. The following is the error I get:

Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\<USERNAME>\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 12.753 secs

I have followed the exact instructions provided in the book, and so I presume that the result should be error free. Any idea why I am facing this error?

lite-whowantstoknow
  • 799
  • 3
  • 9
  • 18
  • I think this might help you: http://stackoverflow.com/questions/23991988/android-studio-0-5-9-2-annoying-gradle-warnings – Orkun Kocyigit Jan 27 '16 at 07:23
  • @OrkunKoçyiğit posting a link to the first result when Google searching for the phrase "Configuration on demand is an incubating feature." isn't going to help. That solution you link to doesn't have anything to do with this question. – tir38 Feb 01 '16 at 18:51

2 Answers2

3

First off a little sanity boost for you

AAPT is exactly related to bundling the resources into your APK. Some great detail here including (IMO) the best diagram showing the different build steps. So your aapt problem aapt.exe'' finished with non-zero exit value 1 is almost certainly caused by your changing the 9-patches. No need to go back to square one, trying to remember what else you may have changed and eventually pulling all your hair out.

Verification

I was unable to duplicate your problem by directly running either of the root Gradle tasks (:app:generateDebugSources and :app:generateDebugAndroidTestSources). Nor was I able to duplicate the problem by running just the failing Gradle task: :app:processDebugResources.

Not caused by Configuration on Demand

It's unlikely that the problem is caused by a failure in the "configuration on demand". The line "Configuration on demand is an incubating feature." will also be printed if your build was successful.

Thoughts

It looks like you are using the latest Build Tools (23.0.2 as of this writing) versions, which is good.

You don't list it, but I'm guessing that you are also using the latest version of the Android-Gradle plugin (since they both came out at the same time and Android Studio defaults to using the latest). more info

What I would suggest is to go back and start with the first Drawable we ask you to implement: the ShapeDrawable and confirm that this works, then move on to the next one. This will help pinpoint where the problem is.

If you could provide link to your sample that would help too.

In the future with Gradle-related problems you can always run the Gradle task yourself (as I did above) and add the --info flag. From command line or "terminal" within Android Studio just run (in your case):

./gradlew app:generateDebugSources --info

Lastly, whatever you discover please post back here. The problem you are seeing isn't directly related to our book and your answer will help others.

tir38
  • 9,810
  • 10
  • 64
  • 107
  • The problem occurs exactly before the 9 patch part of the book. Up until the 9-patch, everything works fine. Then I downloaded the png image and replaced the drawable with it in the layout and it worked. Then I edited it as suggested in the book to create a 9-patch and included that in the layouts. Then, it breaks and won't compile. But replacing the 9-patch with the original drawables in the layouts makes it work again. I moved on from this problem for now as I understood the essence of 9-patch. If I have this issue in the future when I intend to use a 9-patch image I will look into it. – lite-whowantstoknow Feb 15 '16 at 21:34
2

I had the same problem and I resolved it with:

./gradlew clean 
perror
  • 7,071
  • 16
  • 58
  • 85
defend orca
  • 617
  • 7
  • 17