1.使用Android studio新建New Flutter project;
2.最新版本兼容性配置
android-settings.gradle文件下:
pluginManagement {//.......repositories {//阿里云镜像地址:maven { url 'https://maven.aliyun.com/repository/public/' }maven { url 'https://maven.aliyun.com/repository/central' }google()mavenCentral()gradlePluginPortal()}
}plugins {id "dev.flutter.flutter-plugin-loader" version "1.0.0"id "com.android.application" version "8.1.0" apply falseid "org.jetbrains.kotlin.android" version "1.8.22" apply false
}include ":app"
当前为写文章时的最新版本,添加了阿里云镜像地址,同样budil.gradle文件下也需要添加镜像地址;
然后是gradle包下的gradle-wrapper.properties文件:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
当前为gradle-8.3-all.zip,该版本需要对应使用jdk17以上,如当前环境变量未配置或者版本不对应可以在gradle.properties文件下添加配置:
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
org.gradle.java.home=C:\\Users\\user\\.jdks\\corretto-17.0.12
org.gradle.java.home=“你的jdk17安装路径”