How to Resolve Not Able to Sync Dependency In Build.Gradle In Flutter?

· 4 min read
How to Resolve Not Able to Sync Dependency In Build.Gradle In Flutter
How to Resolve Not Able to Sync Dependency In Build.Gradle In Flutter

Sometimes the user needs to make use of Native Android Library when the user adds the library in build. Gradle file he/she started getting error like not able to sync dependency in Build. Gradle. So in this article, we will go through How to Resolve Not Able to Sync Dependency In Build.Gradle In Flutter?

How to Resolve Not Able to Sync Dependency In Build.Gradle In Flutter?

If you’re using Android Studio for Flutter development, right-click on the android folder in your Flutter project. Select “Flutter” -> “Open Android Module in Android Studio“.

or

Simply start Android Studio and open the Android (sub)project directly.

In any case, once the Android Project is opened in Android Studio, you can make changes in your build.gradle. The editor will tell you to sync. Otherwise, simply execute a build. Afterward, you will be able to import using your Android classes.

The problem is with the Gradle sync of the Android project, not with Flutter dependencies.

In your build.gradle of your module add the following module.

implementation 'com.google.android.gms:play-services-vision:10.+'

In dependencies as bellow:

dependencies {
    implementation 'com.google.android.gms:play-services-vision:10.+'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Then open a terminal, cd to an android folder of your flutter project, and run:

$./gradlew build
After that you will be able import com.google.android.gms... in your Java class.

Follow the below steps for the same.

  • Open android studio flutter project
  • Go to file
  • Click on setting
  • Search for “Flutter”

at bottom of that view, there is an experiments section do check that both checkbox
after doing this add any dependencies in android gradle and go to file and click on “Sync with file system” and you are done, please check the below screenshot to do check the experiments item.

Flutter Android Studio
Flutter Android Studio

we managed to sync the dependencies using “Run Configurations“.

  • Open the Gradle tab.

    Build.Gradle Flutter
    Build. Gradle Flutter
  • Select the path to Build. Gradle file.

    Gradle File Flutter
    Gradle File Flutter
  • Double click to sync.

    Sync Android Studio
    Sync Android Studio

Conclusion:

In this article, we have been through How to Solve Not Able to Sync Dependency in build.gradle in Flutter?

Thanks for being with us on a Flutter Journey !!!
Keep Learning !!! Keep Fluttering !!!

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply