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 trialbytepunch
iOS Development with Swift Techdegree Student 5,114 PointsAndroid Studio 3.1.3 on Windows doesn't generate ActivityHourlyForecastBinding so I can't import
I tried (almost) everything to import com.URL.stormy.databinding.ActivityHourlyForecastBinding but nothing works. I rebuilt, cleaned the project. I restarted Android Studio. Changed the name of the .xml file. I done everything I have read on StackOverflow nothing work so far. Any suggestions?
6 Answers
Matthew Timmons
33,804 PointsI had to remove some of the unused import lines at the top of the code, sync with Gradle, and then rebuild the app, and it started working.
Sync with Gradle => Click the Gradle panel on the right side of the screen and then click the sync icon (Two arrows pointing to each other's tails, forming a circle)
Rebuild App => Click the Build option at the top of the screen, then click, "Rebuild Project"
bytepunch
iOS Development with Swift Techdegree Student 5,114 PointsI realized what happened: In the video "Creating a custom layout" at 4.10 Ken explains how to code the <data> ... </data> in "hourly_list_item.xml" but in the later video "Acitivity" at 3.20 you can see that <data> ... </data> appears in "activity_hourly_forecast.xml" and only when you write "data" in your code in the xml-File Android Studio creates the bindind class in the background.
Fahad Saleem
Courses Plus Student 10,786 PointsWhat's the solution? I've been killing myself to fix this problem!
Alex Carduus
8,369 PointsThis resolved the problem for me as well. Thank you!
bytepunch
iOS Development with Swift Techdegree Student 5,114 PointsNo. Everything works fine. https://github.com/apptheism/Stormy
bytepunch
iOS Development with Swift Techdegree Student 5,114 PointsAs I said above. There is an error in the brandnew video and I am surprised that Treehouse didn't respond to my post.
Fahad, just write the same <data> stuff you have written in hourly_list_item.xml in activity_hourly_forecast.xml. I hope Ken will react and correct the videos.
Fahad Saleem
Courses Plus Student 10,786 PointsI did that and the error was gone, but after that, I'm not able to run my app, it's just building gradle and doesn't actually run the app on my external device, I'm using! Did you face any issues like this?
Jonathan Grieve
Treehouse Moderator 91,253 PointsI do this though and all i get is a duplicate attribute error in AS which indicates I can't use the same variable in 2 XML files. I've no other suggestions but this isn't working for me.
Stephanie Youstra
18,513 PointsTagging Ken Alger -- this needs a Teacher's Note to fix.
Stephanie Youstra
18,513 PointsOn another project, I was having the same horrible refusal to import ..... per https://stackoverflow.com/a/39549387, I restarted Android Studio, then rebuilt the project -- and there was my com.example.project.databinding
, all ready to be imported! Hope that helps!
Ben Jakuben
Treehouse TeacherApologies on the slow response here! Ken left Treehouse for an exciting opportunity with MongoDB this past summer, so I'm catching up on some issues like this that have fallen through the cracks. For future students, I've added an instruction step to remedy this issue: https://teamtreehouse.com/library/android-lists-and-adapters-2/displaying-lists-of-data/binding-data-in-the-activity
Jonathan Grieve
Treehouse Moderator 91,253 PointsThat's brilliant Ben, thanks for this. I'm sure this will help out future students
I did end up solving the issue in the end (although kind of by accident). So later on I'll investigate and see if I can link this up in other threads where this issue came up.
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsGood answer! I just wanted to let you know I changed your comment on the question to an answer. This let other students upvote your post and the OP to mark it as the best answer.
Happy Learning!