android studio上能够跑起来的flutter配置

android studio
版本 4.1

bulid.gradle 配置
buildscript {
ext.kotlin_version = '1.4.32'
repositories {
    google()
   mavenCentral()
    maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/jcenter' }
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}

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

allprojects {
  repositories {
    google()
    mavenCentral()
    maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/jcenter' }
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}

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

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

C:\flutter\packages\flutter_tools\gradle 在flutter sdk 中 前100行的配置,主要就是前100行左右,到FlutterPlugin 这个类下面的第一行为止。

   class FlutterExtension {
    /** Sets the compileSdkVersion used by default in Flutter app projects. */
    static int compileSdkVersion = 30

    /** Sets the minSdkVersion used by default in Flutter app projects. */
        static int minSdkVersion = 16

      /** Sets the targetSdkVersion used by default in Flutter app projects. */
      static int targetSdkVersion = 30

/**
 * Specifies the relative directory to the Flutter project directory.
 * In an app project, this is ../.. since the app's build.gradle is under android/app.
 */
String source

/** Allows to override the target file. Otherwise, the target is lib/main.dart. */
String target
}

buildscript {
repositories {
    google()
    mavenCentral()
  maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/jcenter' }
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.0.1'
}
}

/**
 * Some apps don't set default compile options.
 * Apps can change these values in android/app/build.gradle.
 * This just ensures that default values are set.
 */
android {
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

apply plugin: FlutterPlugin

class FlutterPlugin implements Plugin<Project> {
//private static final String DEFAULT_MAVEN_HOST      = "https://mirrors.tuna.tsinghua.edu.cn/flutter/download.flutter.io";

 private static final String DEFAULT_MAVEN_HOST =         "https://storage.googleapis.com";

然后在android studio 项目中的gradle/wrapper 目录下的这样修改
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容