Jetpack 2.1 book projects not working

from the CommonsWare Community archives

At September 30, 2021, 9:42pm, Raptor asked:

Hello,

I am trying to do a rebuild of the Jetpack 2.1 project containing all the modules because I can’t CTRL+click on resources and stuff. However, trying that bumps me into a ton of errors, like:

Could not find androidx.core:core-ktx:1.3.5 (in the ToDoTests module)
Could not find androidx.lifecycle:lifecycle-extensions:2.3.1. (in the UnZipWork and DownloadWork modules)

and so on. If I comment these out eventually the synthetic view declarations don’t work anymore in all the modules.

Any way out of this?


At September 30, 2021, 10:00pm, mmurphy replied:

Change androidx.core:core-ktx:1.3.5 to androidx.core:core-ktx:1.3.2. Change androidx.lifecycle:lifecycle-extensions:2.3.1 to androidx.lifecycle:lifecycle-extensions:2.2.0. For any others, use Google's Maven Repository or https://androidx.tech to find a version near the one the project is asking for.

I don’t know what happened here, but I will get it straightened out with Version 2.2, due out in a couple of weeks.


At September 30, 2021, 10:08pm, Raptor replied:

Done that, now it says “Unresolved reference: synthetic” with a long list of stuff that doesn’t work:

Unresolved reference: toolbar
Variable expected
Unresolved reference: about (the view that was solved by the synthetic mechanism that isn’t working)

etc


At September 30, 2021, 10:23pm, mmurphy replied:

Ah. For that, change apply plugin: 'kotlin-parcelize' to apply plugin: 'kotlin-android-extensions'. I moved all the projects over to view binding, but missed MainActivity in ToDoTests, apparently.


At September 30, 2021, 10:35pm, Raptor replied:

I replaced “‘kotlin-parcelize’” in ~20 modules and now it builds, but the IDE still doesn’t color stuff differently (all the code is the same color) and CTRL+clicking on a view that points synthetically to its XML representation doesn’t work, it doesn’t do anything.

CTRL+clicking on “binding” doesn’t do anything, either.


At September 30, 2021, 10:57pm, mmurphy replied:

What version of Android Studio are you using?

If it is Arctic Fox (or newer), and you have not done so already, consider allowing Studio to upgrade Gradle and the Android Gradle Plugin. For Version 2.2 (set for Arctic Fox), I also have ext.kotlin_version set to 1.5.31 in the top-level build.gradle file.


At September 30, 2021, 10:59pm, Raptor replied:

It’s Android Studio Arctic Fox | 2020.3.1 Patch 2


At September 30, 2021, 11:14pm, mmurphy replied:

Then, if you have not done so already, let Studio upgrade you:


At September 30, 2021, 11:26pm, Raptor replied:

They are already like that.


At September 30, 2021, 11:33pm, Raptor replied:

After invalidate caches/restart^^^

Sync, Rebuild after that changed nothing.


At September 30, 2021, 11:39pm, mmurphy replied:

For appcompat, make sure that you have the dependency.

For databinding, Arctic Fox changed the syntax a bit, so you need to use viewBinding true instead of viewBinding = true in the module’s build.gradle file.

More generally, you may just want to wait 10 days or so, when I have an Arctic Fox edition out and can figure out what went haywire with those dependencies.


At October 3, 2021, 5:35pm, mmurphy replied:

OK, grab the current master content from the GitLab repo. Everything in there builds and runs with Arctic Fox for me here, including from a fresh checkout of the code.


At October 3, 2021, 8:06pm, Raptor replied:

Did a pull, seems to work now. Thanks!