I was loading an Android project that downloaded from Github, the project look fairly recent and nothing weird that I can find. But when I open it, it failed to build with the following error:
Unable to find method 'org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;'. Possible causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Other android projects that were created on my machine works fine. What can be the issue?
The issue was that I upgraded to Android Studio v4, and seem like the download project was created using Android Studio v3. After go to
File/ Project Structure.../
And change the Android Gradle Plugin Version
from 3.3.1
to 4.0.1
and now project loaded fine.
Not sure why Android Studio v4 is not backward compatible with Gradle version 3.
To determine plugin version and required Gradle version, developers can refer the compatibility matrix provided in Android documentation from here.
Plugin version | Required Gradle version |
---|---|
1.0.0 - 1.1.3 | 2.2.1 - 2.3 |
1.2.0 - 1.3.1 | 2.2.1 - 2.9 |
1.5.0 | 2.2.1 - 2.13 |
2.0.0 - 2.1.2 | 2.10 - 2.13 |
2.1.3 - 2.2.3 | 2.14.1 - 3.5 |
2.3.0+ | 3.3+ |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With