我如何添加按钮Google+登录



我在SDK中安装了Google Play服务,然后将其添加到"布局"按钮代码Google 中

    <com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

有一个错误:

Rendering Problems The following classes could not be found:
- com.google.android.gms.common.SignInButton (Fix Build Path, Create Class)
 Tip: Try to build the project.

我在构建文件中添加了一行:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

--> compile 'com.google.android.gms:play-services-ads:8.3.0'

testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/bolts-android-1.2.1.jar')
compile files('libs/Parse-1.10.3.jar')
}

但它仍然不起作用。如何使按钮出现?

您添加了错误的依赖项。您应该添加此用于登录按钮。

compile 'com.google.android.gms:play-services-auth:8.4.0'
您添加的

依赖项仅用于广告

compile 'com.google.android.gms:play-services-ads:8.3.0'

应该是

compile 'com.google.android.gms:play-services:8.3.0'

最新更新