android crashes

We’ve gotten a lot of these errors on android:  Is this something you’ve seen before?  Not sure we are using the latest sdk but we are doing that moving forward.

ComponentInfo{com.playzot.grabbyWord/com.chartboost.sdk.CBImpressionActivity}: java.lang.NullPointerException: uriString
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:470)
at android.net.Uri$StringUri.<init>(Uri.java:460)
at android.net.Uri.parse(Uri.java:432)
at com.chartboost.sdk.impl.ap.a(SourceFile:376)
at com.chartboost.sdk.impl.ai$a.<init>(SourceFile:171)
at com.chartboost.sdk.impl.ai$a.<init>(SourceFile:69)
at com.chartboost.sdk.impl.ai.b(SourceFile:539)
at com.chartboost.sdk.f.c(SourceFile:286)
at com.chartboost.sdk.Model.a.k(SourceFile:298)
at com.chartboost.sdk.e.e(SourceFile:75)
at com.chartboost.sdk.e.a(SourceFile:55)
at com.chartboost.sdk.Chartboost.a(SourceFile:848)
at com.chartboost.sdk.c.a(SourceFile:331)
at com.chartboost.sdk.Chartboost.a(SourceFile:238)
at com.chartboost.sdk.CBImpressionActivity.onStart(SourceFile:56)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1239)
at android.app.Activity.performStart(Activity.java:5322)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2569)

I’ve seen this kind of error before if you are showing video ads, and if you have turned off “Show Post roll confirmation” in the “Rewarded Videos” settings for the app in the Chartboost dashboard. The only way to fix it is to leave “Show Post roll confirmation” on at the moment. Chartboost have some fixes on the way, but I don’t think they are implemented yet.

This only happens on Android.

Can you reproduce this crash yourself?

Thanks for getting back to me.  Unless the chartboost guys changed the setting in my admin (I had previously contacted them without realizing the plugin wasn’t theirs) the setting was already enabled (both pre and post roll checkboxes were checked).  I was going to try to see if I could reproduce the issue myself.  We got quite a few of the exceptions from players over the last several days.

It’s a bit tricky to track down unless the crash can be reproduced. The issue I mentioned above was crashing consistently, so it was possible to isolate.

BTW:

Are these crash reports something that all of a sudden have started to drop in?

In other words, did your app work fine until recently, and you noticed these reports started to come in now?

They were happening within a narrow time frame.  There is a new crash report that started happening today after we re-enabled chartboost.  It seems to be happening when the app is exiting?

java.lang.RuntimeException: Unable to destroy activity {com.playzot.grabbyWord/com.ansca.corona.CoronaActivity}: java.lang.IllegalStateException: Need to intialize chartboost using Chartboost.init() as the application object is null
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3851)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3869)
at android.app.ActivityThread.access$1500(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5635)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Need to intialize chartboost using Chartboost.init() as the application object is null
at com.chartboost.sdk.b.p(SourceFile:370)
at com.chartboost.sdk.Chartboost.onStop(SourceFile:353)
at plugin.chartboost.LuaLoader$3.run(LuaLoader.java:243)
at android.app.Activity.runOnUiThread(Activity.java:5045)
at plugin.chartboost.LuaLoader.onExiting(LuaLoader.java:250)
at com.ansca.corona.CoronaEnvironment$RuntimeEventHandler.onExiting(CoronaEnvironment.java:470)
at com.ansca.corona.CoronaRuntime.onExiting(CoronaRuntime.java:422)
at com.ansca.corona.CoronaRuntime.dispose(CoronaRuntime.java:76)
at com.ansca.corona.CoronaActivity.onDestroy(CoronaActivity.java:694)
at android.app.Activity.performDestroy(Activity.java:5757)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1123)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3833)
… 11 more

java.lang.RuntimeException: Unable to destroy activity {com.playzot.grabbyWord/com.ansca.corona.CoronaActivity}: java.lang.IllegalStateException: Need to intialize chartboost using Chartboost.init() as the application object is null

 
I’ve never seen that one before. 
Is this from your own testing or is it from a user’s device?

It was from 2 user devices reported through google’s crash reporting system.

To me it looks like chartboost.init() failed to initialize properly for those devices, however it’s difficult to tell if that’s the case and why.

I can’t reproduce the issue myself…

It seems to be shutting down though when it tries to init?

To me, it seems to be crashing only when they exit the app. It might just be a glitch in the shutdown sequence and maybe it’s working fine up until then. Not sure what to do since I can’t reproduce it…

Another exception to report on android.  I haven’t been able to reproduce it but google is reporting multiple per day:

java.lang.IllegalStateException: The activity context must be set through the Chartboost onCreate method
at com.chartboost.sdk.b.o(SourceFile:362)
at com.chartboost.sdk.Chartboost.clearCache(SourceFile:503)
at com.chartboost.sdk.Chartboost$a.run(SourceFile:947)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)

Thanks for the report. I’ll put this on the list of observations.

Have you updated your plugin with the latest drop of the chartboost sdk?

Yes. Both the iOS and Android plugin have been updated with the latest SDK from Chartboost (March 17).
You can check if you are using the latest version by printing chartboost.getPluginVersion() from your code.
Android should print 5.1.3 rev 1 and iOS should print 5.1.5 rev 1.

Hello,

I am getting the exact same problem using Chartboost.  I can reproduce it at will on Android. The exact error is as follows:

E/AndroidRuntime( 8095): FATAL EXCEPTION: main

E/AndroidRuntime( 8095): Process: com.gmail.popalzie.TinyCanoeV2, PID: 8095

E/AndroidRuntime( 8095): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmail.popalzie.TinyCanoeV2/com.chartboost.sdk.CBImpressionActivity}: java.lang.NullPointerException: uriString

E/AndroidRuntime( 8095): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2334)

E/AndroidRuntime( 8095): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)

E/AndroidRuntime( 8095): at android.app.ActivityThread.access$900(ActivityThread.java:169)

E/AndroidRuntime( 8095): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)

E/AndroidRuntime( 8095): at android.os.Handler.dispatchMessage(Handler.java:102)

E/AndroidRuntime( 8095): at android.os.Looper.loop(Looper.java:146)

E/AndroidRuntime( 8095): at android.app.ActivityThread.main(ActivityThread.java:5487)

E/AndroidRuntime( 8095): at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime( 8095): at java.lang.reflect.Method.invoke(Method.java:515)

E/AndroidRuntime( 8095): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)

E/AndroidRuntime( 8095): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)

E/AndroidRuntime( 8095): at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime( 8095): Caused by: java.lang.NullPointerException: uriString

E/AndroidRuntime( 8095): at android.net.Uri$StringUri.<init>(Uri.java:467)

E/AndroidRuntime( 8095): at android.net.Uri$StringUri.<init>(Uri.java:457)

E/AndroidRuntime( 8095): at android.net.Uri.parse(Uri.java:429)

E/AndroidRuntime( 8095): at com.chartboost.sdk.impl.ao.a(SourceFile:381)

E/AndroidRuntime( 8095): at com.chartboost.sdk.impl.ai$a.<init>(SourceFile:177)

E/AndroidRuntime( 8095): at com.chartboost.sdk.impl.ai$a.<init>(SourceFile:73)

E/AndroidRuntime( 8095): at com.chartboost.sdk.impl.ai.b(SourceFile:546)

E/AndroidRuntime( 8095): at com.chartboost.sdk.f.c(SourceFile:286)

E/AndroidRuntime( 8095): at com.chartboost.sdk.Model.a.k(SourceFile:299)

E/AndroidRuntime( 8095): at com.chartboost.sdk.e.e(SourceFile:75)

E/AndroidRuntime( 8095): at com.chartboost.sdk.e.a(SourceFile:55)

E/AndroidRuntime( 8095): at com.chartboost.sdk.Chartboost.a(SourceFile:920)

E/AndroidRuntime( 8095): at com.chartboost.sdk.c.a(SourceFile:336)

E/AndroidRuntime( 8095): at com.chartboost.sdk.Chartboost.a(SourceFile:255)

E/AndroidRuntime( 8095): at com.chartboost.sdk.CBImpressionActivity.onStart(SourceFile:56)

E/AndroidRuntime( 8095): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1177)

E/AndroidRuntime( 8095): at android.app.Activity.performStart(Activity.java:5461)

E/AndroidRuntime( 8095): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)

E/AndroidRuntime( 8095): … 11 more

I am using interstitial ads (both video and static) and both types of ads will load without issue on Android most of the time, but it will randomly fail with the above error.

The manner in which I am loading the ads is as follows:

function scence:enterScene(event)

.

.

chartboost.cache(“interstitial”)

.

end

function showInterstitialAd()

if not chartboost.hasCachedInterstitial() then

            chartboost.cache( “interstitial” )

            storyboard.gotoScene( “start” )

        else

            chartboost.show( “interstitial” )

        end

end

end

@popalzie

It looks like the app isn’t always initializing properly.

  1. Where do you call chartboost.init()

  2. Are you handing chartboost.startSession() as described here:

https://github.com/swipeware/CoronaChartboostPlugin/blob/modernized/docs/startSession.markdown

@ingemar

****from build.settings****

[“plugin.chartboost”] =

        {

           publisherId = “com.swipeware”,

        }

****from main.lua*****

local chartboost = require( “plugin.chartboost” )

local myAppID        = “xxxxxxmyappIDxxxxxxx”

local myAppSignature = “xxxxx,myAppSignaturexxxxx”

– Change the appid/sig for Android

if system.getInfo( “platformName” ) == “Android” then

    myAppID        = “xxxxxmyAndroidAppIdxxxxxx”

    myAppSignature = “xxxxxmyAndroidAppSignaturexxxxx”

end

– Change the appid/sig for Amazon Kindle

if ( system.getInfo(“model”) == “Kindle Fire” or system.getInfo(“model”) == “KFJWI” ) then

       myAppID        = “xxxxxmyAndroidAppIdxxxxxx”

    myAppSignature = “xxxxxmyAndroidAppSignaturexxxxxx”

end

–ad listener function

local function adListener( event )

  

      if(event.response==“willDisplay”) then

                  

      end

      if(event.response==“didDisplay”) then

      end

      if(event.response==“closed”) then

          if(mydata.mainMenuClicked==true) then

               mydata.mainMenuClicked=false

            storyboard.gotoScene(“start”)

          else

            storyboard.gotoScene(“game”)

          end

          

      end

      if(event.response==“clicked”) then

        storyboard.gotoScene(“start”)

      end

      if(event.response==“cached”) then

                         

      end

      if(event.response==“failed”) then

       

                             

      end

  end

chartboost.init {

        appID        = myAppID,

        appSignature = myAppSignature, 

        listener     = adListener

    }

The following are things that I have found using adb logcat on the device.

  1. The error (the NullPointerException) occurs multiples times simply on loading the app, meaning that even without serving up an ad.  The app doesn’t immediately crash or anything like that at this point, however, the logs clearly show that this error is occurring.

  2. The app can crash on the very first call to load an ad or the ads can be served up just fine n number of times and then the app will crash on the n+1 attempt.  I can typically make it crash after serving up 5 or so ads on a regular basis.

I agree with you that it appears to be related to the initialization and I also think that it has something to do with Android making a decision to force close the application.  I remember seeing something in the log that basically stated that this application has experienced an error x number of times…now closing the app.  The error read something along those lines which made me think that maybe we are exceeding a threshold of error occurrences before Android steps in and forces close the application.  This would also explain the randomness of the problem…not sure though.

-Mayan

Hi again,

You need to implement chartboost.startSession() as described in the link below, otherwise Chartboost will not behave properly when resuming from an ad (or resuming after using another app).
https://github.com/swipeware/CoronaChartboostPlugin/blob/modernized/docs/startSession.markdown

The error (the NullPointerException) occurs multiples times simply on loading the app, meaning that even without serving up an ad.

 
That’s strange if it happens on the very first start (not resume). I can’t reproduce such a condition.

Have you tried testing your App ID/SIG with the Corona Chartboost sample app?

If not, please download it and give it a try with your App ID and SIG and monitor the logcat to see if you get the same errors on start.

https://github.com/swipeware/CoronaChartboostSample

NOTE:

It’s difficult to read code that’s pasted as plain text. When pasting code into a post, please use a code block (looks like this “< >” in the menubar). 

@ingemar

Sorry, I didn’t know about the code formatting brackets.  

I think you are absolutely correct!  I had that code in my main.lua file and upon trying to integrate a secondary ad provider I commented it out.  When I switched back to only using Chartboost again, I didn’t “uncomment” that line.

I have fixed this and now I am unable to reproduce the crash!  

I was also unable to reproduce the initial errors that occurred when the app just started so it definitely must have been on resuming the application that I just didn’t notice earlier.

Thanks so much for your help.

@rstupek, my apologies for hijacking your thread (definitely not my intention).  It appeared as though we were facing the same issue.  Hopefully, the recommendation fixes yours as well.

Thanks again.

@popalzie

Hey. Great to hear that your issue is resolved!

@rstupek

The very first error you posted is the same as popalzie’s. Maybe it could be due the same issue of not implementing chartboost.startSession()?