【问题标题】:How to fix this gradle sync issue如何解决这个 gradle 同步问题
【发布时间】:2020-02-22 08:29:38
【问题描述】:

我收到此错误 错误:在项目 ':app' 上找不到参数 [目录 'libs'] 的方法 implementation()。 打开文件 这些是 build.grade(Module : app) 的内容

//noinspection GradleCompatible
//noinspection ExpiredTargetSdkVersion
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "spoorthy.shopping"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

等级文件(项目:购物)

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects {
    repositories {
        jcenter()
    }
}

【问题讨论】:

标签: java android android-studio


【解决方案1】:
    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.waltonbd.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/raw'] } }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

在 defaultConfig{} 中添加 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"。同时添加 buildToolVersion

同时添加 google()

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // 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
}

【讨论】:

  • 错误:在存储库容器上找不到参数 [] 的方法 google()。
  • 升级gradle。如果你不想升级,那么使用`maven { url 'maven.google.com' } `
  • 你的gradle版本太低了。依赖项 { classpath 'com.android.tools.build:gradle:1.3.0' } . 更新它。转到帮助->检查更新
  • 如果您通过任何答案解决了您的问题,请投票。因为它证明你的问题已经解决了。 @匿名
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-29
  • 1970-01-01
  • 2021-09-14
  • 2014-10-07
  • 1970-01-01
相关资源
最近更新 更多