Layer7 Mobile API Gateway: End of input at character 0

book

Article ID: 195366

calendar_today

Updated On:

Products

CA Mobile API Gateway

Issue/Introduction

When launching an Android app using the Mobile SDK you may experience an app crash on startup.

The below error is observed in Logcat

 

2020-07-17 10:09:14.470 6288-6288/com.ca.mas.massample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ca.mas.massample, PID: 6288
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ca.mas.massample/com.ca.mas.massample.MainActivity}: com.ca.mas.core.error.MAGRuntimeException: org.json.JSONException: End of input at character 0 of 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: com.ca.mas.core.error.MAGRuntimeException: org.json.JSONException: End of input at character 0 of 
        at com.ca.mas.core.conf.ConfigurationManager.getConfig(ConfigurationManager.java:216)
        at com.ca.mas.core.conf.ConfigurationManager.getConfig(ConfigurationManager.java:189)
        at com.ca.mas.core.conf.ConfigurationManager.activateDefault(ConfigurationManager.java:165)
        at com.ca.mas.core.conf.ConfigurationManager.load(ConfigurationManager.java:160)
        at com.ca.mas.core.conf.ConfigurationManager.getConnectedGatewayConfigurationProvider(ConfigurationManager.java:119)
        at com.ca.mas.foundation.MASConfiguration.getIdTokenSignAlg(MASConfiguration.java:177)
        at com.ca.mas.foundation.MAS.isAlgoRS256(MAS.java:105)
        at com.ca.mas.foundation.MAS.init(MAS.java:100)
        at com.ca.mas.foundation.MAS.start(MAS.java:168)
        at com.ca.mas.massample.MainActivity.onCreate(MainActivity.java:58)
        at android.app.Activity.performCreate(Activity.java:7009)
        at android.app.Activity.performCreate(Activity.java:7000)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
     Caused by: org.json.JSONException: End of input at character 0 of 
        at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
        at org.json.JSONTokener.nextValue(JSONTokener.java:97)
        at org.json.JSONObject.<init>(JSONObject.java:159)
        at org.json.JSONObject.<init>(JSONObject.java:176)
        at com.ca.mas.core.conf.ConfigurationManager.getConfig(ConfigurationManager.java:212)
        at com.ca.mas.core.conf.ConfigurationManager.getConfig(ConfigurationManager.java:189) 
        at com.ca.mas.core.conf.ConfigurationManager.activateDefault(ConfigurationManager.java:165) 
        at com.ca.mas.core.conf.ConfigurationManager.load(ConfigurationManager.java:160) 
        at com.ca.mas.core.conf.ConfigurationManager.getConnectedGatewayConfigurationProvider(ConfigurationManager.java:119) 
        at com.ca.mas.foundation.MASConfiguration.getIdTokenSignAlg(MASConfiguration.java:177) 
        at com.ca.mas.foundation.MAS.isAlgoRS256(MAS.java:105) 
        at com.ca.mas.foundation.MAS.init(MAS.java:100) 
        at com.ca.mas.foundation.MAS.start(MAS.java:168) 
        at com.ca.mas.massample.MainActivity.onCreate(MainActivity.java:58) 
        at android.app.Activity.performCreate(Activity.java:7009) 
        at android.app.Activity.performCreate(Activity.java:7000) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Cause

The issue occurs because the configuration file, msso_config.json, was not loaded.

 

Resolution

If you are starting the SDK using the standard method, MAS.start(Context context), make sure you have included a valid msso_config.json in your project's assets directory.