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 android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:802) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) 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:
Another point of note is that it seems all other Google Play service calls compile. For example, I am make a call to GooglePlayServicesUtil.isGooglePlayServicesAvailable
with no apparent issues.
Can anybody steer me in the correct direction?
Using the Google+ sign-in button:
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
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:
dependencies{
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.
You should add this line to your app's build.gralde:
compile 'com.google.android.gms:play-services:8.3.0'
The latest version is 9.0.2, 4.4.52 is some too older.
In summary, Integrating Google Sign-In into Your Android App has a bug. You must add the above line to your build.gradle file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With