当Flutter中使用了path_provider
时,pubspec.yaml
中配置了path_provider
依赖,并执行Pub get
时,程序执行gradle assembleDebug,出现如下错误
PUB_HOSTED_URL=https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
guava:26.0-jre
、kotlin-reflect-1.3.11
等path_provider
依赖仍然需要外网访问权限依次点击:android—>Flutter—>Open Android module in Android Studio
android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
android\gradle\wrapper\gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
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/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
//classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
//google()
//jcenter()
//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/'}
}
}
D:\SoftWare\flutter
aar_init_script.gradle
project.repositories {
maven {
//url "$storageUrl/download.flutter.io"
url "https://storage.flutter-io.cn/download.flutter.io"
}
}
flutter.gradle
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' }
}
class FlutterPlugin implements Plugin {
//private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn/download.flutter.io";
}
resolve_dependencies.gradle
repositories {
//google()
//jcenter()
//maven {url "$storageUrl/download.flutter.io"}
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 "https://storage.flutter-io.cn/download.flutter.io"}
}
依次点击:File—>Settings—>Appearance&Behavior—>System Settings—>HTTP Proxy
点击Check connection
,输入外网网址如(https://youtube.com/)
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=443
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.auth.ntlm.domain=domain
此处,没有密码,顾设置如下
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8580
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8580
此处设置的代理同步保存在
C:\Users\Admin\.gradle\gradle.properties
不想使用代理,可在项目的gradle.properties和此处的gradle.properties删除代理设置
gradlew clean
gradlew build