引入了阿里的播放器:flutter_aliplayer:^5.4.9
android打包时出现下面错误
* What went wrong:
A problem occurred configuring project ':flutter_aliplayer'.
> Could not resolve all dependencies for configuration ':flutter_aliplayer:classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/repositories/releases)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':flutter_aliplayer' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':flutter_aliplayer' of type org.gradle.api.Project.
gradle7.0之后使用http就会报错,处理方法就是添加allowInsecureProtocol = true
maven {
allowInsecureProtocol = true
url ...
}
或者 在.gradle目录下 init.gradle 文件中添加allowInsecureProtocol的全局判断
allprojects {
repositories {
def REPOSITORY_URL = 'http://127.0.0.1:8081/repository/maven-public/'
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven { ArtifactRepository repo ->
// 判断属性是否存在,之后再设置
if(repo.metaClass.hasProperty(repo, 'allowInsecureProtocol')){
allowInsecureProtocol true
}
url REPOSITORY_URL
}
}
}
。。。但是发现没有地方使用http://maven.aliyun.com/nexus/content/repositories/releases
这个地址
真的是苦逼了好久。。。
最后在阿里云上找到源码下载
找到了gradle-wrapper.properties文件然后看到了gradle6.5版本
这个时候突然就顿悟了。。立即点开build.gradle
果然有一行http
maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
Q.E.D.