JasCav JasCav - 2 years ago 245
Android Question

Cannot Render Google+ SignInButton

I am attempting to follow the Setting Up Google Play Services tutorial for Android Studio 0.8.6. Ultimately, I want to add the Google+ sign-in button to my app (see below for example). When I add the button to my XML, the preview pane (as well as the app itself when I deploy it in debug mode) gives the following error message:

Rendering Problems The following classes could not be instantiated:
- com.google.android.gms.common.SignInButton (Open Class, Show Exception) Tip: Use View.isInEditMode() in your custom views to skip
code or show sample data when shown in the IDE

Exception Details
java.lang.ClassNotFoundException: com.google.android.gms.dynamic.f
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)   at
java.lang.ClassLoader.loadClass(ClassLoader.java:247)   at
java.lang.ClassLoader.defineClass1(ClassLoader.java:-2)   at
java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)   at
java.lang.ClassLoader.defineClass(ClassLoader.java:621)   at
java.lang.ClassLoader.defineClass(ClassLoader.java:471)   at
java.lang.ClassLoader.loadClass(ClassLoader.java:306)   at
java.lang.ClassLoader.loadClass(ClassLoader.java:247)   at
com.google.android.gms.common.SignInButton.z  at
com.google.android.gms.common.SignInButton.setStyle  at
com.google.android.gms.common.SignInButton.  at
com.google.android.gms.common.SignInButton.  at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)   at
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:778)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:500)   at
android.view.LayoutInflater.inflate(LayoutInflater.java:381) Copy
stack to clipboard

I have seen and have attempted to follow steps found in similar questions (most of which are related to Eclipse). I have also attempted to:

  • Clean the build.

  • Resync Gradle

  • Invalidate Caches / Restart

  • Re-get the libraries.

Another point of note is that it seems all other Google Play service calls compile. For example, I am make a call to
with no apparent issues.

Can anybody steer me in the correct direction?

Using the Google+ sign-in button:

android:layout_height="wrap_content" />

Answer Source

I believe this is a bug in the latest Google Play Services (5.0) code and/or integration with gradle and Android Studio.

I had the same problem and I was able to get around it by downgrading the version of Google Play Services used in my project. I added the following in the build.gradle under the dependencies section:

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

After that, the error went away and the layout designer was able to render the Google+ Sign-In button on the screen.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download