如何添加按钮Google+登录?

时间:2016-01-02 19:55:29

标签: java android google-plus google-plus-signin

我在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')
}

但它仍然无效。我该如何制作按钮外观?

2 个答案:

答案 0 :(得分:1)

您添加了错误的依赖项。您应该为登录按钮添加此内容。

compile 'com.google.android.gms:play-services-auth:8.4.0'

答案 1 :(得分:0)

您添加的依赖项仅适用于广告

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

应该是

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