Android Android Lists and Adapters Adapters and ViewHolders Activity

apptheism
apptheism
1,678 Points

Android 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?

2 Answers

Matthew Timmons
Matthew Timmons
24,070 Points

I 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"

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 36,952 Points

Good 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!

apptheism
apptheism
1,678 Points

I 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.