1

I have been trying to install Google Play Services for quite a few hours, but after trying to search everywhere I can't seem to find a solution to my problem. I think I have imported both the BaseGameUtils and the PlayGamesServices, and Android Studio automatically recognizes these in my app now, which for me seem like they are implemented.

However when I try to add the sign in button

<com.google.android.gms.common.SignInButton
    android:id="@+id/bHighScore"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button1"
    android:layout_alignBottom="@+id/button1"
    android:layout_marginLeft="98dp"
    android:layout_toRightOf="@+id/button1"
    android:text="Highscore"
    />

It says

The following classes could not be instantiated:
- com.google.android.gms.common.SignInButton (Open Class, Show Exception)
java.lang.VerifyError: Expecting a stackmap frame at branch target 13

Exception Details: Location: com/google/android/gms/common/SignInButton.setStyle(II)V @1: iflt Reason: Expected stackmap frame at this location.

Bytecode:

0000000: 1b9b 000c 1b06 a200 0704 a700 0403 1206
0000010: 04bd 0014 5903 1bb8 002c 53b8 0028 1c9b
0000020: 000c 1c05 a200 0704 a700 0403 1207 04bd
0000030: 0014 5903 1cb8 002c 53b8 0028 2a1b b500
0000040: 182a 1cb5 0015 2a2a b600 23b7 0027 b1  

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658)
at java.lang.Class.getConstructor0(Class.java:2964)
at java.lang.Class.getConstructor(Class.java:1812)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:310)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
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)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:586)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:528)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:523)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

And when I open the class it says Sources not found and I have no idea what to put in the attached sources.

Any help would be greatly appreciated.

Ordboka
  • 13
  • 4
  • Google Play Services is closed source, you can't attach any source to it, and it's not the source of your problem. Judging by the error message, your compiled code may be incompatible with what Android expects. I would suggest you first try removing Google Play Services and related code to first confirm that this is actually what's causing the problem. – Kai Jul 31 '14 at 12:47
  • I think you are correct. It might be a problem with the BaseGameUtils class, but that sadly gets me no closer to the solution. – Ordboka Jul 31 '14 at 13:43
  • you should edit your question's title/description/tags to clarify your question in light of the fact that it's not really related to Google Play Services, maybe more people will be able to help then. – Kai Jul 31 '14 at 13:56
  • I changed the title, but it's still realted to Google Play Services since this library is one given with Google Play Services. – Ordboka Jul 31 '14 at 14:43

1 Answers1

0

I had this same issue, along with a compilation problem.

If you are attempting to compile to java 8 jdk bytecode, then the problem is actually in android itself -- Android only supports up to the java 7 jdk discussed here. However, you can, as mentioned in that article, try using retro-lambda, which via voodoo I don't understand converts java 8 bytecode back to java 7.

This does not mean you can't use jdk 1.8, you just have to compile to java 7 bytecode, and therefore natively cannot use java 8 syntactic sugar.

To fix this in your mobile build.gradle (here's what mine was)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId "com.example"
        minSdkVersion 17
        targetSdkVersion 'L'
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    apply plugin: 'findbugs'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile 'com.google.android.gms:play-services:5.0.89'
}

change the compile options to:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
Community
  • 1
  • 1
thejava
  • 108
  • 2
  • 10