android - 导入 Volley 库后,gradle构建失败

标签 android gradle

我已通过引用此项目在我的项目中实现了电话号码检测和SMS验证功能
https://www.programcreek.com/java-api-examples/?code=android%2Fidentity-samples%2Fidentity-samples-master%2FSmsVerification%2Fapp%2Fsrc%2Fmain%2Fjava%2Fcom%2Fgoogle%2Fsamples%2Fsmartlock%2Fsms_verify%2Fui%2FPhoneNumberActivity.java#
我从下面的链接下载并导入了 Volley
https://github.com/google/volley
构建项目时出现错误,请指导我我是android studio的新手...
错误

Unable to find method 'org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()Lorg/gradle/api/file/FileCollection;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt
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.1.1-all.zip
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
更新:
我从C:\ Users \ MY PC.gradle \ wrapper \ dists删除了gradle文件并重建了项目,现在出现了此错误

Error Unknown host 'services.gradle.org'. You may need to adjust the proxy settings in Gradle. Enable Gradle 'offline mode' and sync project Learn about configuring HTTP proxies in Gradle

最佳答案

将gradle-wrapper.properties中的distributionUrl更改为distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip以使构建再次运行。这似乎是一个类似的问题Gradle sync failed: Unable to find method.

关于android - 导入 Volley 库后,gradle构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63480665/

相关文章:

android - 如何在android studio中使用fabric插件安装twitter kit

android - gradle设置:找不到com.google.android.gms.internal.zzbgl

gradle - 多模块项目 gradle - 多个或单个 build.gradle

android - Gradle构建突然无法说 'Could not get unknown property ' testInstrum'…'

java - 配置 'compile' 已过时,已替换为 'implementation' 和 'api' 。将于2018年底删除

android - 使用 Loopback Android SDK 访问后端

android - ListView 中的 "Separators"

android - setMinimumWidth() 在 android View 中使用什么测量单位?

android - 为每个数据条目在一行上显示带有按钮的数据

android - Flutter项目中任务 ':app:processDebugResources'执行失败