2017-07-14 65 views
-3

我試圖運行我的android工作室,因爲2天,最後它顯示錯誤400和我的build.gradle文件看起來像這錯誤:(40,0)無法找到參數[目錄'庫']的方法實現()

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

allprojects { 
repositories { 
    jcenter() 
} 
} 
apply plugin: 'com.android.application' 

android { 
compileSdkVersion 25 
buildToolsVersion '25.0.1' 
defaultConfig { 
    applicationId "com.armenhovhannisyan.backpaper.backpaper" 
    minSdkVersion 25 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner      "android.support.test.runner.AndroidJUnitRunner" 
    vectorDrawables.useSupportLibrary = true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro' 
    } 
} 
productFlavors { 
} 
} 

dependencies { 
implementation fileTree(dir: 'libs', include: ['*.jar']) 
androidTestImplementation('com.android.support.test.espresso:espresso- core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:25.0.0-beta1' 
testImplementation 'junit:junit:4.12' 
implementation 'com.android.support:design:25.0.0-beta1' 
implementation 'com.android.support.constraint:constraint-layout:1.0.2' 
compile 'com.android.support:support-annotations:25.3.1' 
} 

更新和做一些改變,以我的gradle.properties文件,它看起來像這樣

# Project-wide Gradle settings. 

# IDE (e.g. Android Studio) users: 
# Gradle settings configured through the IDE *will override* 
# any settings specified in this file. 

# For more details on how to configure your build environment visit 
# http://www.gradle.org/docs/current/userguide/build_environment.html 

# Specifies the JVM arguments used for the daemon process. 
# The setting is particularly useful for tweaking memory settings. 
org.gradle.jvmargs=-Xmx1536m 

# When configured, Gradle will run in incubating parallel mode. 
# This option should only be used with decoupled projects. More details, visit 
#  http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decou pled_projects 
# org.gradle.parallel=true 
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1- all.zip 
+0

你爲什麼要執行''而不是'compile'?請參閱https://developer.android.com/studio/build/dependencies.html編輯:我只是讀了一些文章,顯然'編譯'將被棄用來gradle 3.0。 – nbokmans

+0

你不能在android gradle 2.XX中使用'implementation',你需要android gradle插件3.0.0(目前在alpha中)或更多 – MatPag

回答

9

後,它應該是compile而不是implementation和Android的具體測試中,它的androidTestCompile。它應該看起來像這樣

compile fileTree(include: ['*.jar'], dir: 'libs') 
testCompile 'junit:junit:4.12' 
compile'com.android.support:design:25.0.0-beta1' 
compile'com.android.support.constraint:constraint-layout:1.0.2' 
+1

我改變了gradle文件,但現在它顯示了這個.......... ....................錯誤:(40,0)無法在org.gradle類型的對象上找到參數[目錄'libs']的方法complie()。 api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。 – kunal007

+0

@ kunal007嘗試交換像這樣的參數'編譯fileTree(包括:['* .jar'],dir:'libs')' –

+0

@ kunal007這是一個錯字嗎?它是'compile'而不是'complie'。 –

相關問題