Can't use Android Gradle Plugin 3.0.+ with Int

2019-01-28 00:28发布

问题:

When I'm trying to use Android Gradle Plugin 3.0.+ with Intellij IDEA, I'm getting error: Error:This Gradle plugin requires Studio 3.0 minimum

But my version of IntelliJ is higher than 2017.2 and it should work with gradle plugin for AS 3.0.

回答1:

It can be fixed by adding this option to your gradle.properties:

android.injected.build.model.only.versioned=3

Explanation:

From Reddit /r/androiddev

A version check is in place in ModelBuilder that is fed by Gradle properties inserted by the IDE when you execute the Sync action. The fix is to add the following to gradle.properties: android.injected.build.model.only.versioned=3

AS 3.0 is sending the value 3, whereas older versions as well as IntelliJ send 1 or lower, if they send a value at all. Once set as specified, sync works again and everything so far has been operating normally.

Full answer with comments from Android Studio team

UPDATE

IntelliJ IDEA 2018.1+ supports Android Gradle Plugin 3.0+!



回答2:

Adding the android.injected.build.model.only.versioned=3 property in the gradle.properties file (as suggested here) will get the Gradle sync working but you may run into issues when trying to deploy your Android app onto a device or emulator from within IntelliJ. For that you'll probably have to use Android Studio 3.x or one of the install Gradle tasks... until a version of IntelliJ IDEA is released that supports Android 3.x features (keep an eye on this JetBrains issue).