Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync failed: Exception thrown while executing model rule: BaseComponentModelPlugin.Rules#createVariantData(ModelMap

I was running android application very well then i updated Android Studio to 3.0 and Gradle version to latest 4.1. After Synch the project i got following build error

    e.project.sync.GradleSyncState - Gradle sync failed: Exception thrown while executing model rule:
BaseComponentModelPlugin.Rules#createVariantData(ModelMap<AndroidBinaryInternal>, ModelMap<AndroidComponentSpec>, TaskManager) > afterEach()

I will be thankful for this quick favour.

like image 400
Salman Nazir Avatar asked Nov 01 '17 14:11

Salman Nazir


People also ask

How do I fix gradle sync failed?

Then open Android Studio and go to File > Settings > Build, Execution and Deployment > Gradle > Use Gradle from > Set the path of the downloaded Gradle. Step 4. Now try syncing the Gradle again and check if the error still persists.

How do I fix gradle sync issues in IntelliJ?

We can configure the settings for how IntelliJ IDEA syncs with Gradle by pressing the settings icon in the Gradle tool window, and selecting Auto-Reload Settings. We can set IntelliJ IDEA to automatically reload the project after "Any changes" in the build script files, so changes are automatically reloaded.


1 Answers

Temporary solution, which worked for me, was to change the following things:

  1. In top level .gradle file - change version of experimental plugin to 0.9.3:

    dependencies { classpath 'com.android.tools.build:gradle-experimental:0.9.3' classpath 'com.google.gms:google-services:3.0.0' }

  2. Change Gradle plugin version from 4.1 to 3.3 in gradle-wrapper.properties

    distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

It works with android studio 3.0

like image 190
Kamen Stoykov Avatar answered Dec 23 '22 04:12

Kamen Stoykov