首页 > 解决方案 > Android Studio 未找到库

问题描述

当我尝试构建项目时,新的 Android Studio 版本(3.2.1)遇到了很多问题。

我正在使用 android-sunflower(jetpack 集成)项目,但出现以下错误。

其他人是否收到此错误?

 Plugin [id: 'com.diffplug.gradle.spotless', version: '3.13.0'] was not found in any of the following sources:

    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Plugin Repositories (could not resolve plugin artifact 'com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:3.13.0')
      Searched in the following repositories:
        Gradle Central Plugin Repository
    Open File

标签: androidandroid-studioandroid-gradle-plugin

解决方案


将此调整为您项目的顶级 build.gradle 文件。添加插件和一尘不染。

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'

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

plugins {
id "com.diffplug.gradle.spotless" version "3.4.0"
}

allprojects {
repositories {
    jcenter()
}

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
    }
}

apply plugin: 'com.diffplug.gradle.spotless'

spotless {
    java {
        target "**/*.java"
        trimTrailingWhitespace()
        removeUnusedImports()
        googleJavaFormat()
    }
}
 }

task clean(type: Delete) {
delete rootProject.buildDir
}

推荐阅读