首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到对象上的参数[目录'libs']的方法实现()

找不到对象上的参数[目录'libs']的方法实现()
EN

Stack Overflow用户
提问于 2018-07-02 13:06:57
回答 3查看 26.1K关注 0票数 8

错误消息:-未能找到org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.类型对象上的参数目录'libs‘的方法实现() 代码

代码语言:javascript
复制
apply plugin: 'com.android.application'

ext {
    supportVersion='27.1.1'
}
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.eassycars.www.dlservices"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildscript {
        repositories {
            jcenter()
        }
        configure(':app') {
        dependencies {
            classpath 'com.android.tools.build.gradle:4.8.1'
            implementation fileTree (include: ['*.jar'], dir: 'libs')
            implementation "com.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler :$supportVersion"
            implementation "com.android.support:appcompat-v7:$supportVersion"
            implementation "com.android.support:cardview-v7:$supportVersion"
            implementation "com.android.support:recyclerview-v7:$supportVersion"
            implementation "com.android.support:design:$supportVersion"
            implementation "com.android.support:palette-v7:$supportVersion"
            implementation "com.android.support:customtabs:$supportVersion"
            implementation "com.android.support:support-v4:$supportVersion"
            implementation 'com.google.android.exoplayer:exoplayer:r2.0.4'
            // utils
            implementation 'com.github.bumptech.glide:glide:4.0.0'
            annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
            implementation 'com.koushikdutta.ion:ion:2.1.7'
            implementation 'com.github.Commit451:bypasses:1.0.4'
            implementation 'com.jakewharton:butterknife:8.8.0'
            annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
            implementation 'com.drewnoakes:metadata-extractor:2.9.1'
            implementation 'com.orhanobut:hawk:2.0.1'
            classpath 'com.google.gms:google-services:3.1.1'
            implementation 'com.android.support:support-annotations:27.1.1'
        }}
    }
}
EN

回答 3

Stack Overflow用户

发布于 2018-12-28 22:32:35

我更新了我的gradle /wrapper/gradle-Wrapper.properties文件中的"distributionUrl“,以匹配当前的gradle版本。

我还更新了顶级build.gradle文件中的类路径,以匹配gradle API级别。

代码语言:javascript
复制
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

重新同步,然后它建立了OK。

票数 2
EN

Stack Overflow用户

发布于 2018-07-02 13:11:38

删除版本之间的空格:

代码语言:javascript
复制
implementation "com.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler:$supportVersion"

此外,请将依赖项块移出android块:

代码语言:javascript
复制
android {
...
}
...
dependencies{
...
}
票数 0
EN

Stack Overflow用户

发布于 2018-07-02 13:14:43

因为您的build.gradle中有错误的块。看起来你把顶级 build.gradle和模块build.gradle混合起来了。您的应用程序模块build.gradle应该如下所示:

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    ...
  }
  buildTypes {
    release {
      ...
    }
  }

  ..
}

dependencies {
  ...
}

详情请访问配置您的构建

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51136966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档