SAP / gigya-android-sdk

SAP CDC (Gigya) android sdk for mobile
Apache License 2.0
19 stars 13 forks source link

RuntimeException: Error creating Gigya SDK (did you forget to Gigya.setApplication or missing apiKey?) #32

Closed lo-g closed 2 years ago

lo-g commented 2 years ago

Hi! I'm facing this crash while doing explicit init within release config:

init {
        GigyaLogger.setDebugMode(BuildConfig.DEBUG)
        Gigya.setApplication(application)
        Gigya.secureActivityWindow(BuildConfig.DEBUG.not())
    }

    private val instance = Gigya.getInstance(GigyaAccount::class.java).apply {
        init(
            "MY-API-KEY",
            "MY_DOMAIN"
        )
    }
  isMinifyEnabled = true
  isShrinkResources = true
  isDebuggable = false

Any ideas? With debug config all woks well.

Gigya core version: core-v5.1.4

tal-mi commented 2 years ago

Hi,

Are you using the JSON configuration "gigyaSdkConfiguration.json" file?

Tal

lo-g commented 2 years ago

Hi, nope because my goal is to initialize it dynamically. When my app starts I fetch API key and domain from a server and then I'm trying to initialize Gigya.

tal-mi commented 2 years ago

Initiate the Gigya.getInstance(GigyaAccount::class.java) call only after you receive the API key. Once the instance is created the SDK fetches required configurations from the server. The API Key is mandatory at that point.

tal-mi commented 2 years ago

An initialization fix was applied in v5.1.5. Please update and verify.

lo-g commented 2 years ago

Thanks for support, with v5.1.5 the crash is still present. I've created a simple project here where you can reproduce the issue.

tal-mi commented 2 years ago

Thank you. I will verify and update.

tal-mi commented 2 years ago

Hi. The SDK currently does not support minification. You will need to add it to your proguard rules. -keep class com.gigya.android.sdk.* { ; }

lo-g commented 2 years ago

Thanks @tal-mi. I've added this rules.

burhanshakir commented 1 year ago

@tal-mi Unfortunately, I am facing the same issue as above even after adding the -keep class com.gigya.android.sdk.** { *; }rule to the proguard file. I am on the v7.0.3 of the Android SDK and this is how I am initialising the SDK in the application class:

GigyaLogger.setDebugMode(BuildConfig.DEBUG)
Gigya.setApplication(this)
Gigya.getInstance().init(BuildConfig.SAP_API_KEY, "eu1.gigya.com")

I am also using the Gigya NSS SDK, not sure if that could be causing an issue here ?

The error only happens for non-debug builds with these flags:

isRemoveUnusedCode = true
isRemoveUnusedResources = true
isObfuscate = true
isOptimizeCode = true