我在android studio中不是很神,但是我正在努力使它工作。 但是当我陷入困境时,我现在不该做什么。 所以现在我希望有人能帮助我。
我有5个错误。
错误:无法解决:com.google.android.gms:play-services-auth-api-phone:11.8.0
错误:无法解决:com.google.android.gms:play-services-basement:11.8.0
错误:无法解决:com.google.android.gms:play-services-auth-base:11.8.0
错误:无法解决:com.google.android.gms:play-services-tasks:11.8.0
错误:无法解决:com.google.android.gms:play-services-base:11.8.0
我无法安装存储库和同步项目。
这是我的礼物:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 16
targetSdkVersion 25
versionCode 9
versionName "1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url uri('mint-plugin-repo-5.1.0')
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//For error logcat
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.android.support:design:25.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-auth:11.0.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:4.12.1'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.intuit.sdp:sdp-android:1.0.4'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.splunk:mint-android-sdk:5.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.daasuu:CountAnimationTextView:0.1.1'
compile 'com.facebook.android:account-kit-sdk:4.+'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:1)
添加jcenter()
并将其添加到implementation
之前,这很重要,还必须使用compile
而不是buildscript {
repositories {
google() // add this
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
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 {
google() // add this
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 16
targetSdkVersion 25
versionCode 9
versionName "1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url uri('mint-plugin-repo-5.1.0')
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
repositories {
mavenCentral()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//For error logcat
implementation 'com.google.android.gms:play-services:11.0.4'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
implementation 'com.mikhaellopez:circularimageview:3.0.2'
implementation 'com.android.support:design:25.3.1'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.google.android.gms:play-services-auth:11.0.4'
implementation 'com.google.android.gms:play-services-gcm:11.0.4'
implementation 'com.android.support:support-annotations:25.3.1'
implementation 'com.facebook.android:facebook-android-sdk:4.12.1'
implementation 'com.google.firebase:firebase-messaging:9.0.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.intuit.sdp:sdp-android:1.0.4'
implementation 'com.google.maps.android:android-maps-utils:0.4.+'
implementation 'com.koushikdutta.ion:ion:2.+'
implementation 'com.splunk:mint-android-sdk:5.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.daasuu:CountAnimationTextView:0.1.1'
implementation 'com.facebook.android:account-kit-sdk:4.+'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
这:
tvLoginWith.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
override fun onGlobalLayout() {
tvLoginWith.viewTreeObserver.removeOnGlobalLayoutListener(this)
tvLogin.layoutParams.width = tvLoginWith.width
tvLogin.requestLayout()
}
})
答案 1 :(得分:0)
您需要将google()
添加到项目级别的build.gradle文件中。在jcenter()
之前添加它。
另外,请注意,compile
已过时,应改为使用implementation
。
如果上述方法不起作用,则可能需要禁用“文件>>设置>>构建,执行,部署>> Gradle >>离线工作”上的gradle离线工作选项。