自从我更新了 android gradle 后,我的铃声应用程序出现了问题,我猜问题出在复制文件和权限上(我注意到 list 中的 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>
谁能告诉我解决问题的正确方法和步骤
最佳答案
以下是您可以尝试的步骤,但这不是解决问题的好方法。您最好专注于主要问题并尝试解决它。从 here 开始或寻找其他解决方法。
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.x.x):
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
4-同步。
关于android - 如何降级android gradle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52214442/