android - 如何降级android gradle?
问题描述
由于我更新了android gradle,我的铃声应用程序出现了问题,我猜问题出在复制文件和权限上(我注意到清单中的android.permission.WRITE_SETTINGS带有红色下划线,我猜是有问题)
相同的代码在我的旧项目中完美运行,唯一的区别在于 gradle,所以我在网上尝试了一些关于如何降级的教程,但我失败了。
我尝试在gradle-wrapper.properties(Gradle Version)中进行更改
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
到以前对我有用的版本,但我收到消息说 4.4 是最低的
然后我尝试在build.gradle(Project)中降级
但仅成功将其降级为
类路径'com.android.tools.build:gradle:3.0.1'
但这并没有解决我的问题,因为工作版本是2.3.3
与distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
当我尝试与 2.3.3 同步时出现错误
Gradle DSL method not found: 'google()'
Possible causes:<ul><li>The project 'MyProject' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.1.4 and sync project</li><li>The project 'MyProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
有人可以告诉我正确的方法并逐步解决我的问题吗
解决方案
以下是您可以尝试的步骤,但这不是解决问题的好方法。你最好专注于主要问题并尝试解决它。从这里开始或找到其他解决方法。
1-从 build.gradle 中删除 google() 并添加 maven:(对于低于 4.1 的 Gradle)
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
2-转到gradle-wrapper.properties
并将gradle版本更改为:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
3-将 gradle 插件更改为(如果您使用的是 Android Studio 2.xx):
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
4-同步。
推荐阅读
- arrays - 高效地堆叠和连接 NumPy 数组
- python - 对远程主机的 Elasticsearch Python 索引操作不起作用(连接被拒绝)但 cURL 工作正常
- python - 我如何让列表匹配列表中最后一个单词中的任何字母?
- excel - 如何覆盖重复项,使用 Excel VBA 根据特定单元格值追加新行?
- javascript - 如何在我的 react js 应用程序中实现搜索功能?
- ruby-on-rails - 使用 GET 请求提交的 Rails 表单未在 URL 中放置查询字符串参数
- flutter - 多行 TextSpan 中的识别器问题
- android - 如何在第一个下方显示另一个输出?
- javascript - 为什么即使在 .then 中,数据也会在 for 循环中返回 undefined
- javascript - 无法在 for 循环中打印更新的数组值