ClassCastException: java.lang.Integer cannot be cast to java.lang.String

880 views
Skip to first unread message

Jose Grillo

unread,
May 20, 2020, 11:26:16 AM5/20/20
to Interactive Media Ads SDK
Grettings, could you please help me, I´m trying to migrate ours current Android Sdk Version (3.16.0) to the newest one (3.19.0) but this has been quite dificult because didn't find updated documentation to migrate to this new version, could please told where could I find an example or documentation of how to migrate to this one?, Currently the lines told to have deprectaed funcs,

sdkFactory.createAdDisplayContainer()

adDisplayContainer?.adContainer = viewGroup

With
createAdDisplayContainer and adContainer being deprecated, but didn´t find any clear instruction with what should they be replaced, annd also, if I try to run the project with the version, and those deprecated elements, android gives me this Log

Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
        at com.google.ads.interactivemedia.v3.internal.aiq.k(IMASDK:18)
        at com.google.ads.interactivemedia.v3.internal.ail.doInBackground(IMASDK:13)

But this doesn´t give any clue because of the Proguard applied to the sdk?

Could please give any light here?

Best regards.

IMA SDK

unread,
May 20, 2020, 5:22:08 PM5/20/20
to joseenriq...@i3television.es, ima...@googlegroups.com
Hi Jose,

Thank you for reaching out to us. The changes made to the IMA SDK for Android from v3.16.0 to v3.19.0 are minor, therefore, we didn't publish any migration guide. However, you can take a look at our Android AdvancedExample sample as it will show you how to use the new API methods. In our AdvancedExample sample app, the AdDisplayContainer was created on this line.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5004Q1zqfmu:ref

Jose Grillo

unread,
May 21, 2020, 4:15:23 AM5/21/20
to Interactive Media Ads SDK
Grettings, thanks Arnaud, I have made the changes, but still the weird issue appears

2020-05-21 10:09:44.671 23379-23567/com.antena3.ondaceroradio E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
    Process: com.antena3.ondaceroradio, PID: 23379
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:318)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

     Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
        at com.google.ads.interactivemedia.v3.internal.aiq.k(IMASDK:18)
        at com.google.ads.interactivemedia.v3.internal.ail.doInBackground(IMASDK:13)
        at android.os.AsyncTask$2.call(AsyncTask.java:304)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

I have seen this issue sinnce the version 3.16.2, where you introduce SharedPreferences support, do you have any hint of what could this been happing, trying to investigate, this is telling me that the at com.google.ads.interactivemedia.v3.internal.aiq.k(IMASDK:18) is the import, on some class I couldn't see, with the import of ImaSdkFactory?

Does this tell you something?

Best regards.

IMA SDK

unread,
May 21, 2020, 6:40:14 AM5/21/20
to joseenriq...@i3television.es, ima...@googlegroups.com

Hi Jose,

 

Thank you for getting back to us on this.

 

I tried to use the advanced sample app v3.16, this sample app uses the SDK version 3.16.2 as default SDK. I've updated the SDK version to version 3.19.0 and this triggers the deprecation of createAdDisplayContainer method. Following the AdDisplayContainer implementation as shown in this line. I was able to build the app successfully and I wasn't able to reproduce the issue that you're facing.

 

That being said, could please try the above sample app and update the SDK to the latest version and see if you will encounter the same issue? Please let us know the result.

 

Regards,

Sherwin Diesta

Jose Grillo

unread,
May 27, 2020, 11:09:06 AM5/27/20
to Interactive Media Ads SDK
Grettings Sherwing, after several tries the issue is still happening, here is my implementation for sdk initialization, do you something is missing or something that could explain that weird exception with the shared preferences.

I keep that this happen since I try to aply the version .16.2 up

sdkSettings = sdkFactory.createImaSdkSettings()
adsRenderingSettings = sdkFactory.createAdsRenderingSettings()
adDisplayContainer = ImaSdkFactory.createAdDisplayContainer(viewGroup, this)
adsRenderingSettings?.enablePreloading = true
sdkSettings?.isDebugMode = BuildConfig.DEBUG
emVideoView?.blockPlayback = true
adsLoader = sdkFactory.createAdsLoader(context, sdkSettings, adDisplayContainer)
adsLoader?.addAdsLoadedListener(this)
adsLoader?.addAdErrorListener(this)
...

The bug is


Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
        at com.google.ads.interactivemedia.v3.internal.aiq.k(IMASDK:18)
        at com.google.ads.interactivemedia.v3.internal.ail.doInBackground(IMASDK:13)

Best regards.

IMA SDK

unread,
May 27, 2020, 5:11:10 PM5/27/20
to joseenriq...@i3television.es, ima...@googlegroups.com
Hi Jose,

The issue you reported is not with the IMA SDK, I've run our AdvancedExample (v3.16.2) sample several times and was not able to reproduce the error message you shared. Your implementation is at many points different from ours, we create the AdDisplayContainer passing the AdUIContainer and the video ad player to the createAdDisplayContainer method, in your implementation, you're passing a viewGroup and the keyword this. When it comes to register to the events listeners, we're passing callbacks to the
addAdsLoadedListener and addAdsErrorListener, in your use case you're passing the keyword this. The best thing would to debug your implementation against our Android AdvancedExample to fix the issue you're facing.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5004Q1zqfmu:ref
Reply all
Reply to author
Forward
0 new messages