[英]How to add library google play service in android studio successfully
我嘗試在android studio中通過Maven
添加庫google play service
,但它會遇到很多問題。
第一個問題是Multiple dex files define
:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.android.gms:play-services:+'
}
我研究過,改成這樣:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// compile 'com.google.android.gms:play-services:+'
compile 'com.google.android.gms:play-services:4.3.23'{
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:18.0.+'
}
但我得到其他錯誤Build script error, unsupported Gradle DSL method found: 'com.google.android.gms:play-services:4.3.23()'!
我不知道為什么我得到這個bug。
人們可以告訴我如何通過Maven
成功添加庫google play service
到項目?
謝謝,
我必須修改我的build.gradle文件,如下所示:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android.gms:play-services:+'
}
重啟android studio並同步我的項目。 問題解決了
謝謝大家
我了解在Android工作室添加庫google play service
時,我關注鏈接: 帶有Google Play服務的Android Studio
右鍵單擊您的應用程序,然后打開模塊設置
以下是我的build.gradle文件的頂部:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
// http://gradleplease.appspot.com/
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.googlecode.android-query:android-query:0.25.9'
compile 'com.android.support:support-v13:19.0.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.jsoup:jsoup:1.7.3'
compile 'org.apache.commons:commons-io:1.3.2'
compile files('libs/libGoogleAnalyticsServices.jar')
}
如dependencies
中的注釋中所述,您可以訪問http://gradleplease.appspot.com/獲取其中許多內容的最新版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.