簡體   English   中英

如何降級android gradle?

[英]How to downgrade 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-同步。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM