我試圖將外部庫添加到我現有的項目中。我創建了一個libs文件夾,並在根目錄下添加了我的MaterialDrawer庫。這裏是我的settings.gradle文件:錯誤:未找到Gradle DSL方法:'google()'
include ':app'
include 'libs:MaterialDrawer'
但gradle這個同步失敗並獲得以下錯誤:
Error:Gradle DSL method not found: 'google()'
我無法找到關於SO我的問題的任何解決方案。任何人都會友善地幫忙?
這裏是的build.gradle(項目):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// 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" }
}
}
這裏是的build.gradle(APP):
機器人{ compileSdkVersion 25 buildToolsVersion '25 .0.0 '
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 38
versionName "2.1.8"
generatedDensities = []
}
dexOptions {
javaMaxHeapSize "4g"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io"}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":libs:MaterialDrawer")
}
apply plugin: 'com.google.gms.google-services'
添加存儲庫{ maven {url:https://maven.google.com' //替代網址在項目的gradle中爲'https://dl.google.com/dl/android/maven2/' } } –
仍然收到錯誤消息。 :( –
@ noob-Sci-Bot在'libs'目錄中是否有任何jar庫?爲'MaterialDrawer'發佈'build.gradle'。爲什麼在應用'build.gradle'中使用'repositories'部分? – DeKaNszn