SAP / gigya-flutter-plugin

Plugin for easily integrating SAP CDC functionality and flows into your Flutter app.
Apache License 2.0
14 stars 15 forks source link

Error creating Gigya SDK #14

Open kidandcat opened 3 years ago

kidandcat commented 3 years ago

I'm getting this error when creating a release APK:

E/AndroidRuntime(13063): java.lang.RuntimeException: Unable to start activity ComponentInfo{es.sonypictures.reactions/es.sonypictures.reactions.MainActivity}: java.lang.RuntimeException: Error creating Gigya SDK (did you forget to Gigya.setApplication or missing apiKey?)
E/AndroidRuntime(13063):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3322)
E/AndroidRuntime(13063):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3471)
E/AndroidRuntime(13063):        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
E/AndroidRuntime(13063):        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(13063):        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(13063):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2058)
E/AndroidRuntime(13063):        at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(13063):        at android.os.Looper.loop(Looper.java:226)
E/AndroidRuntime(13063):        at android.app.ActivityThread.main(ActivityThread.java:7592)
E/AndroidRuntime(13063):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13063):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/AndroidRuntime(13063):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

I've tried configuring Gigya's ApiKey using the two methods available:

https://sap.github.io/gigya-android-sdk/sdk-core/ I've configured the Gigya SDK following the instructions, and it works when running in debug mode.

tal-mi commented 3 years ago

Sorry for the delayed response. I will investigate the issue and update as soon as I can.

tal-mi commented 3 years ago

Where did you put the following line of code? Gigya.setApplication(this);

kidandcat commented 3 years ago

In development mode it works without that line.

But I put it here to try (although it still doesn't work in release mode): image

We had all the commented code previowsly, but after upgrading the plugin we removed it and it still works in develop mode.

The problem happens only when running in release mode or creating a release APK.

tal-mi commented 3 years ago

Yes. from the latest version "setApplication" is not needed as the plugin handles the SDK initialization. I will continue to investigate the issue and update as soon as I can.

Are you using: minifyEnabled true?

kidandcat commented 3 years ago

I don't think so, I'll check it again.

Edit: no, it is not enabled

tal-mi commented 3 years ago

Please attach the following so I can inspect it better:

  1. A detailed log/error of the release build process.
  2. Release build steps (apk/bundle...).

Thanks

kidandcat commented 3 years ago

Build output: build.txt

build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "es.sonypictures.reactions"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
   }

    buildTypes {
        debug {
           signingConfig signingConfigs.release
        }
        release {
           signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'android.arch.work:work-runtime:1.0.0'
    implementation project(":fluzo-sdk-2.2.0-PRO")
    implementation "androidx.core:core-ktx:+"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.facebook.android:facebook-android-sdk:5.+'
}
tal-mi commented 3 years ago

Can you also provide detailed log of the error?

Thanks.

kidandcat commented 3 years ago

That was a cached build, this is a clean one: build.txt

Regarding the error, what I post in the first message is all I get. And it only happens when running the release APK or running flutter in release mode (but then I don't have any logs, it just crashes)

tal-mi commented 3 years ago

Please try to add the following and update me if anything changes.

buildTypes {
        debug {
           signingConfig signingConfigs.release
        }
        release {
           shrinkResources false
           minifyEnabled false
           signingConfig signingConfigs.release
        }
    }
kidandcat commented 3 years ago

It's working with these options, thanks!

Maybe minifying or shrinking is removing the json config of Gigya? Is there any way of having it working with shrinking?

tal-mi commented 3 years ago

Okay. I will investigate further to see why theses options are necessary. The Gigya core SDK currently does not support shrinking (its a feature that will be added). I will see what can be done to prioritize it. Thanks you.

kidandcat commented 3 years ago

Is not a top priority anyway. I'm closing this issue, but it would be great to have the no shrink option in the documentation.

Thanks for the quick response!

kidandcat commented 3 years ago

Any news on this? We are shipping our app to production and without shrinking and minify the app size is unmanageable (>200MB).

tal-mi commented 3 years ago

Shrinking support is not scheduled for Q4 this year. You can try initializing the SDK via the new initSDK feature added last version.

KarlChow92 commented 2 years ago

Encountering same issue unfortunately.

John-Dormevil commented 1 year ago

This error is produce without shrinking MissingPluginException(No implementation found for method initSdk on channel gigya_flutter_plugin)

pwa-tapptic commented 10 months ago

This error is produce without shrinking MissingPluginException(No implementation found for method initSdk on channel gigya_flutter_plugin)

Same here. Have you found a workaround for this?

pwa-tapptic commented 10 months ago

Not found it in the doc but I checked example app and I fixed the issue by adding manually two dependencies in build.gradle

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'