我的 android 工作室找不到编译方法(com.android.support.constraint:constraint-layout:1.0.0-beta4)

my android studio can`t find compile method(com.android.support.constraint:constraint-layout:1.0.0-beta4)

我在 Android Studio 中遇到了这个问题,我在 build.gradle 文件中添加了这个,但我遇到了那个问题。

Error:(13, 0) Could not find method compile() for arguments [com.android.support.constraint:constraint-layout:1.0.0-beta4] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

// 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:3.0.0'
        compile'com.android.support.constraint:constraint-layout:1.0.0-beta4'                                
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
     }
    }

    allprojects {
     repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
     }
    }

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

Beta 4 是旧版本。尝试使用 1.0.2 代替:

compile 'com.android.support.constraint:constraint-layout:1.0.2'  

删除这一行:

compile'com.android.support.constraint:constraint-layout:1.0.0-beta4' 

不能在顶层文件中添加依赖,你也不能在[=11]中使用这个依赖=]块。