I’m at the start of chapter 02 and already am encountering Gradle issues due to how out of date the book is.
When I create the directory BuildSrc
and its corresponding file build.gradle.kts
, first it requires me to update the Gradle version.
I update the Gradle version to 7.3 and this is the error I’m getting when I’m trying to sync:
Cannot invoke “org.gradle.tooling.model.gradle.BasicGradleProject.getName()” because “project” is null
How do I fix this?
Hello lenduya,
This past year we’ve been seeing multiple updates in all the libraries that we’re using. We’re currently looking at this - thank you for reporting.
I’m currently looking at this and:
- The current version works fine with the latest stable version of Android Studio (Flamingo 2022.2.1 Patch 2).
- The latest stable version is Gradle 8.0.0 and requires some more updates.
To update to Gradle 8.0.0:
- On buildSrc/Dependencies.kt update
android_gradle_plugin
to 8.0.0
- Go to gradle/wrapper/gradle-wrapper.properties and update the
distributionUrl
to feth gradle-8.1-bin.zip
- Synchronize the project
You should now have an error saying:
Namespace not specified
This is because it’s now mandatory to define it on build.gradle.kts.
Go to androidApp/build.gradle.kts and inside the android
section add:
namespace = "com.raywenderlich.findtime.android"
Now you’ll need to do a similar step for shared configuration.
Go to shared/build.gradle.kts and inside the android
section add:
namespace = "com.raywenderlich.findtime"
Synchronize the project and compile your app; everything should be alright now