Not able to sync dependency in build.gradle in flutter

前端 未结 5 1172
渐次进展
渐次进展 2021-01-01 19:41

I want to use some native library. and I am using below dependnecy

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

in build.gradle in

相关标签:
5条回答
  • 2021-01-01 19:51

    That is the problem with gradle sync of Android project, not with Flutter dependencies.

    In your build.gradle of your module (for example android/app/build.gradle of your Flutter project) add:

    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 terminal, cd to 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.

    0 讨论(0)
  • 2021-01-01 19:59

    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. Afterwards you will be able to import use your Android classes.

    0 讨论(0)
  • 2021-01-01 20:03

    Go to android folder of your flutter project and then

    open it in terminal by right clicking on that folder

    then try to run below command

    gradlew build

    0 讨论(0)
  • 2021-01-01 20:11

    i know i am late but let me suggest the way as per i done and it's working , if it helps to someone

    1. Open android studio flutter project
    2. Go to file
    3. Click on setting
    4. Search for "Flutter"
    5. 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

    0 讨论(0)
  • 2021-01-01 20:18

    I managed to sync the dependencies using "Run Configurations". Please follow next screenshots:

    1. Open Gradle tab.

    2. Select path to Build.Gradle file.

    3. Double click to sync.

    0 讨论(0)
提交回复
热议问题