Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Anunay Sinha
Anunay Sinha
3,179 Points

Android - Data Binding class is not getting generated.

My Weather app project's build constantly keeps failing and ArrayIndexOutOfBoundsException was thrown with Java Compiler returning error code -1 while trying to build the project.

This happened while I was using Android's Data Binding Library. I enabled dataBinding in the build.gradle but even then the problem persists. I checked up the documentation and even the environment set-up notes but couldn't find any solution.

Please help me out with this.

2 Answers

Binyamin Friedman
Binyamin Friedman
14,615 Points

I think you misinterpreted the cause of the error. ArrayIndexOutOfBounds would mean that you are retrieving an item that doesn’t exist from an array.

Is there any place in your code where you might be retrieving a negative index of an array or perhaps an index larger than the size of the array? Remember that arrays start at 0.

Did the error tell you what line it was on? I don’t think it should be related to your environment.

Anunay Sinha
Anunay Sinha
3,179 Points

Hey Binyamin, I have checked throughout and am sure that I haven't used any array in my code.

Also, the error did not tell me the line number, the project keeps failing to build with error description as "Task Exception:app:MergeDebugResources failed"

It even showed a popup titled "IDE Error" asking to submit the error report to google.

P.S : It happened when I tried to generate a ActivityMainBinding class.

Binyamin Friedman
Binyamin Friedman
14,615 Points

Are any of your gradle imports incompatible with each other or do any of them have different version numbers that might interfere?

Anunay Sinha
Anunay Sinha
3,179 Points

No there's no problem while syncing the project files with gradle normally.

But when I include "dataBinding{enabled = true}" in my build.gradle for app module, the build fails and shows the same error I mentioned above.

Also I noticed an absurd behaviour with this project only while using constraint layouts.

In the FunFacts app project there's no problem while generating the binding class.

As far as the versions are considered, I am using the latest Android Studio with latest plugin for gradle.

Anunay Sinha
Anunay Sinha
3,179 Points

I don't think my gradle imports are incompatible because there's no problem in syncing. The build step fails.

Binyamin Friedman
Binyamin Friedman
14,615 Points

I don't think I can help you with this :(