Android中的Google登录按钮错误 [英] Google Sign-in button error in Android
问题描述
$ b <1>包含按钮:
< com.google.android.gms.common.SignInButton
android:id =@ + id / sign_in_button
android:layout_width =wrap_content
android:layout_height =wrap_content/>
<2>编辑顶层构建文件
classpath'com.google.gms:google-services:1.5.0-beta2'
3)编辑应用程序级构建文件
apply plugin:'com.google.gms。 google-services'
现在我在按钮UI中出现错误,因为
Blockquote
无法找到以下类:
- com.google.android.gms.common.SignInButton(修复构建路径,创建类)
请帮我解决这个问题!
首先我们需要澄清一下,你应该有2 build.gradle
文件。其中一个是项目级文件,另一个是应用级Gradle文件:
这些文件应该如下所示:
Project:StackOverlfow
build.gradle:
buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com。 android.tools.build:gradle:1.1.0'
classpath'com.google.gms:google-services:1.5.0-beta2'
//注意:不要将您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
存储库{
jcenter()
模块:app
gradle文件:
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion21.1.2
defaultConfig {
applicationIdcom.example.package
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName1.0.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'),'proguard-rules.pro'
}
}
}
依赖关系{
编译fileTree(dir:'libs' ,包括:['* .jar'])
编译'com.google.android.gms:play-services-aut h:8.4.0'
}
如果您没有安装Google Play服务,请执行以下操作:
- 转至Android Studio - >首选项 - >外观&行为 - >系统设置 - > Android SDK。
- 您将在底部看到一个Launch Standalone SDK Manager。
- 点击它,您将打开独立的SDK Manager窗口。
- 向下滚动到Extras,选择Google Play Services并点击更新。
这将安装合适的播放服务包。完成后,返回到Android Studio并重新同步您的Gradle文件。
I try to include Google sign-in button in my android app by following steps:
1) Including the button:
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
2) Editing Top-level build file
classpath 'com.google.gms:google-services:1.5.0-beta2'
3) Editing App-level build file
apply plugin: 'com.google.gms.google-services'
Now I am getting error in button UI as
Blockquote The following classes could not be found: - com.google.android.gms.common.SignInButton (Fix Build Path, Create Class)
Please help me solve this issue!
First of all we need to clarify that you should have 2 build.gradle
files. One of them is a project-level file and the other one is an app-level Gradle file:
These files should look like this:
Project: StackOverlfow
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module: app
gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.package"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-auth:8.4.0'
}
If you don't have Google Play Services installed, please do the following:
- Go to Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK.
- You'll see on the bottom part a "Launch Standalone SDK Manager".
- Click that and you'll have the standalone SDK Manager window opened.
- Scroll all the way down to "Extras" pick "Google Play Services" and hit update.
This will install the proper play services packages. Once done, go back to the Android Studio and re-sync your Gradle file.
这篇关于Android中的Google登录按钮错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!