Test Project
Test Project

Reputation: 41

How to configure flutter project in android studio?

I installed all the flutter requirements including the flutter and dart plugins for android studio successfully and nothing is missing. I created a new flutter project without selecting Kotlin support, yet after I created the project I got this code with problem related to kotlin

Kotlin version that is used for building with Gradle (1.2.71) differs from the one bundled into the IDE plugin (1.3.50)

And this is the build.gradle file code:

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The other problem is in this diretory : android/app/src/build.gradle. I get an error related to the line of code :

throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")

When I move the mouse on the function name I see this :

Cannot resolve symbol 'GradleException'

This is the gradle.properties content:

org.gradle.jvmargs=-Xmx1536M

android.useAndroidX=true
android.enableJetifier=true

Upvotes: 0

Views: 3376

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80934

Update kotlin in the build.gradle to the following:

ext.kotlin_version = '1.3.50'

or check the answer here


Inside the local.properties file add the path to the flutter sdk location:

flutter.sdk=/path/to/your/flutter/sdk
flutter.buildMode=debug

Upvotes: 0

Related Questions