2017-06-21 59 views
1

我收到以下错误:没有发现过Android Studio摇篮DSL方法:“编译()”

Error:(4, 0) Gradle DSL method not found: 'compile()' 
Possible causes:The project 'Jp' may be using a version of Gradle that does not contain the method. 
Open Gradle wrapper file.The build file may be missing a Gradle plugin. 

我试图寻找其他类似的问题,但毫无效果。 我的build.gradle(项目:JP)文件是如下:
错误:(4,0)摇篮DSL方法未找到: '编译()'

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

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

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

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

的build.gradle(模块:应用)

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.0" 

    defaultConfig { 
     applicationId "com.example.jal.jp" 
     minSdkVersion 19 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile project(":sdk-audio-1.60.1") 

    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1' 
    compile 'com.android.support:design:26.0.0-alpha1' 
} 

的build.gradle(SDK音频-1.60.1)

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.0" 

    defaultConfig { 
     applicationId "com.example.jal.jp" 
     minSdkVersion 19 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile project(":sdk-audio-1.60.1") 

    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1' 
    compile 'com.android.support:design:26.0.0-alpha1' 
} 

settings.gradle:

include ':app', ':sdk-audio-1.60.1' 

任何人都可以帮我解决这个问题吗?

感谢

回答

0

你的Gradle构建工具显得过于陈旧,在根的build.gradle更改以下行:

classpath 'com.android.tools.build:gradle:1.5.0' 

classpath 'com.android.tools.build:gradle:2.3.3' 

而且不要忘了添加google maven to your build.gradle too:

maven { url "https://maven.google.com" } 

这是因为所有支持库被移动在https://developer.android.com/topic/libraries/support-library/revisions.html到Maven作为在发布说明:

Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

所以,那么你的根的build.gradle将是这样的:

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

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

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

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

错误:(1 ,0)支持的最小Gradle版本是3.3。当前版本是2.8。如果使用gradle包装,请尝试编辑C:\ Users \ Jal \ Jp \ gradle \ wrapper \ gradle-wrapper.properties中的distributionUrl到gradle-3.3-all.zip 我照你所说做过,但是我得到了这个错误。你能帮忙吗? –

+0

这意味着你应该升级gradle。尝试将** C:\ Users \ Jal \ Jp \ gradle \ wrapper \ gradle-wrapper.properties **中的行更改为'distributionUrl = https \://services.gradle.org/distributions/gradle-3.3-all。 zip'在 –

+0

我做到了..它永远建设..感谢很多尽管..赞赏它。 –

相关问题