kloder-games / godot-gpgs

Godot Module for Google Play Game Services
MIT License
56 stars 16 forks source link

Godot game crashes when using this module and calling gpgs.init(get_instance_ID()) #1

Open bmercury opened 7 years ago

bmercury commented 7 years ago

I like this module, feels so clean and organised. It has so many features I would LOVE to use, because there are not many google play game services modules for Godot. I followed instructions, compiled, edited projects config file and set up my game in the online console. My apps name is "squane" I have this code in the _ready():

if Globals.has_singleton("GodotGooglePlayGameServices"):
       gpgs = Globals.get_singleton("GodotGooglePlayGameServices")
       gpgs.init(get_instance_ID())

But the app opens, and then it crashes. I used Android_sdk/tools Monitor to check why it crashed and I pasted the logs in here: https://pastebin.com/CakwcV2w The last logs before it crashes are at the bottom of the file.

I hope you can help, because I have no other hopes...

jlopezcur commented 7 years ago

Thanks for your comments :) Could you give me a minimal code for make some test? on an overview I see that there are a problem with the libraries of Android (Drive, Games, ...) so I would like to make some test on my computer. I only need the initialization until this method is called. I think something is missing.

bmercury commented 7 years ago

Sure, I will use pastebin again :+1: I have a scene "data.tscn" in which I have one base node to which I have a script attached. This is scene is in a singleton, so it gets loaded before others(I guess) I will give you the _main() function of this singleton scene(This is the function calling gpgs.init() ) https://pastebin.com/siwg954i

If you need more code, feel free to ask :)

jlopezcur commented 7 years ago

I think here could be the same issue as #2 .

¿Did you follow the instructions on the godot page? http://docs.godotengine.org/en/stable/development/compiling/compiling_for_android.html#requirements Under the Requirements:

Android SDK version 23.0.3 [Note: Please install all Tools and Extras of sdk manager] Android build tools version 19.1 Android NDK r13 or later I think Android build tools version 19.1 have the missing library.

Run again your Android SDK Manager and be sure to install it.

Look when you can and told me. I will try to be more quick with the answer.

bmercury commented 7 years ago

This is interesting. Yes, I followed the instructions, everything you listed is installed.

I tried again, recompiled and used your demo project. It still crashes after init function is called.

jlopezcur commented 7 years ago

Let's see the file /godot/platform/android/build.gradle.template Here is one used in my games:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
    }
}

apply plugin: 'com.android.application'

allprojects {
    repositories {
    mavenCentral()
    $$GRADLE_REPOSITORY_URLS$$
    }
}

dependencies {
    compile 'com.android.support:support-v4:23.+'  // can be removed if minSdkVersion 16 and modify DownloadNotification.java & V14CustomNotification.java
    $$GRADLE_DEPENDENCIES$$
}

android {

    lintOptions {
        abortOnError false
        disable 'MissingTranslation'
    }

    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        $$GRADLE_DEFAULT_CONFIG$$
    }
    // Both signing and zip-aligning will be done at export time
    buildTypes.all { buildType ->
        buildType.zipAlignEnabled false
        buildType.signingConfig null
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src'
                $$GRADLE_JAVA_DIRS$$
            ]
            resources.srcDirs = [
                'res'
                $$GRADLE_RES_DIRS$$  
            ]
            res.srcDirs = ['res']
        //            libs.srcDirs = ['libs']
            aidl.srcDirs = [
                'aidl'
                $$GRADLE_AIDL_DIRS$$   
            ]
            assets.srcDirs = [
                'assets'
                $$GRADLE_ASSET_DIRS$$
            ]
            jniLibs.srcDirs = [
                'libs'
                $$GRADLE_JNI_DIRS$$
            ]
        }
        debug.jniLibs.srcDirs = [
            'libs/debug'
            $$GRADLE_JNI_DIRS$$
        ]
        release.jniLibs.srcDirs = [
            'libs/release'
            $$GRADLE_JNI_DIRS$$
        ]
    }
    applicationVariants.all { variant ->
        // ApplicationVariant is undocumented, but this method is widely used; may break with another version of the Android Gradle plugin
        variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk"))
    }
}
apply plugin: 'com.google.gms.google-services'

Compare with yours and tell me if you see any difference.

bmercury commented 7 years ago

Just checked. It differs in some places. There isn't apply plugin: 'com.google.gms.google-services' in mine at the bottom. And there isn't classpath 'com.google.gms:google-services:3.0.0' in mine at the top under dependencies.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        $$GRADLE_CLASSPATH$$
    }
}

apply plugin: 'com.android.application'

allprojects {
    repositories {
        jcenter()
    mavenCentral()
    $$GRADLE_REPOSITORY_URLS$$
    }
}

dependencies {
    compile 'com.android.support:support-v4:23.+'  // can be removed if minSdkVersion 16 and modify DownloadNotification.java & V14CustomNotification.java
    $$GRADLE_DEPENDENCIES$$
}

android {

    lintOptions {
        abortOnError false
        disable 'MissingTranslation'
    }

    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        $$GRADLE_DEFAULT_CONFIG$$
    }
    // Both signing and zip-aligning will be done at export time
    buildTypes.all { buildType ->
        buildType.zipAlignEnabled false
        buildType.signingConfig null
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src'
                $$GRADLE_JAVA_DIRS$$
            ]
            res.srcDirs = [
                'res'
                $$GRADLE_RES_DIRS$$  
            ]
        //            libs.srcDirs = ['libs']
            aidl.srcDirs = [
                'aidl'
                $$GRADLE_AIDL_DIRS$$   
            ]
            assets.srcDirs = [
                'assets'
                $$GRADLE_ASSET_DIRS$$
            ]
            jniLibs.srcDirs = [
                $$GRADLE_JNI_DIRS$$
            ]
        }
        debug.jniLibs.srcDirs = [
            'libs/debug'
            $$GRADLE_JNI_DIRS$$
        ]
        release.jniLibs.srcDirs = [
            'libs/release'
            $$GRADLE_JNI_DIRS$$
        ]
    }
    applicationVariants.all { variant ->
        // ApplicationVariant is undocumented, but this method is widely used; may break with another version of the Android Gradle plugin
        variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk"))
    }
}

$$GRADLE_PLUGINS$$

Do I change it to be like yours?