把目录flutter/examples/hello_services/android/导入到Android Studio中。
点击File >New >New Module,选择Import .JAR/.AAR Package,添加AAR文件。打开工程属性,添加依赖模块就可以了。
文章转自: https://blog.csdn.net/qq_34777982/article/details/108810701
用Android Stduio创建Flutter项目的时候,会出现各种问题,踩了一个又一个,最后编译的时候可能会出现一直显示Running Gradle task 'assembleDebug'然后就不动了,或者会显示Could not resolve io.flutter等问题,归根结底是网络无法访问到Google服务引起的,两种解决方案:
1.具有比较良好的访问谷歌的网络环境
2.修改镜像源为国内的:
找到Flutte SDK目录下的Flutter打包配置文件flutter.gradle
路径为flutter\packages\flutter_tools\gradle\flutter.gradle
第一处配置:
buildscript {
repositories {
//注释
// google()
// jcenter()
//添加
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:3.5.0'
}
}
第二处配置:
class FlutterPlugin implements Plugin<Project>{
//注释
// private static final String MAVEN_REPO = " https://storage.googleapis.com/download.flutter.io "
//添加这行
private static final String MAVEN_REPO = " https://storage.flutter-io.cn/download.flutter.io "
第三处配置:
void addFlutterDependencies(buildType) {
String flutterBuildMode = buildModeFor(buildType)
if (!supportsBuildMode(flutterBuildMode)) {
return
}
String repository = useLocalEngine()
? project.property('local-engine-repo')
: MAVEN_REPO
最后一处,项目中的配置,修改Flutter项目下的android下的build.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
//google()
//jcenter()
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' }
}
}
allprojects {
repositories {
//google()
//jcenter()
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' }
}
}
修改完成后,再build,就可以正常构建了!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)