Flutter 问题
dart下载网址:
Dart for Windows (gekorm.com)
flutter中文网站:
Flutter SDK 版本列表 | Flutter 中文文档 | Flutter 中文开发者网站
安装环境
Android toolchain
Android SDK 里设置 Android SDK Location 为 Androidsdk安装根目录 android-sdk\current
Android SDK
Android SDK -> SDK Platforms 选择所需版本下载
要勾选show package details选项框,才会显示出所有版本号
下载的路径是Android SDK location对应的路径,而flutter doctor 检测的路径是环境变量PATH,此二者务必对应上!
Android BuildTools
Android SDK -> SDK Tools -> Android SDK BuildTools 里选择所需版本下载
Android license
执行命令
flutter doctor --android-licenses
结果
Review licenses that have not been accepted (y/N)? y
...... y
...... y
All SDK package licenses accepted
问题1:
- Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to
resolve this.
解决方法: - Android SDK Command-line Tools 选择所需版本安装
问题2: - A newer version of the Android SDK is required.
解决方法: - 去升级, sdkmanager --update
依赖下载
- 在android/build.gradle中将google() jcenter()删掉,换成aliyun的仓库,外加一个download.flutter.io
- 在$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"中同样
buildscript {
repositories {
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' }
maven { url 'http://download.flutter.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
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' }
maven { url 'http://download.flutter.io' }
}
}
buildscript {
repositories {
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' }
maven { url 'http://download.flutter.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
不要使用pub get或pub upgrade命令来管理你的依赖关系。相反,应该使用flutter packages get或flutter packages upgrade。如果您想手动使用pub,则可以通过设置FLUTTER_ROOT环境变量来直接运行它。
gradle问题
安卓gradle插件和版本对应关系
问题:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven4(http://------)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
解决方法:
使用allowInsecureProtocol属性解决gradle的仓库地址不安全警告,指定通过不安全的HTTP连接与仓库通信是否可接受,如果该属性的值设置为true,则表示接受"不安全"的仓库地址
maven {
allowInsecureProtocol = true
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
maven {
allowInsecureProtocol = true
url 'http://download.flutter.io'
}
问题:
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
解决方法:
gradle.properties 中设置所需Java_home
org.gradle.java.home=D:\\Application\\Scoop\\apps\\OracleJDK17\\current
.gitignore的生成
androidstudio检测不到手机
问题:在打开开发者选项以及USB调试已经打开,但仍然检测不到。
解决办法:
- 在选择USB选项中,也要选择MIDI。
- 要打开ADB调试。