Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Cast SDK v3 Crashing in Release build only

Whenever I try to run a release build of my app, I immediately get a crash when attempting to use any of the Google Cast features

java.lang.IllegalStateException: Failed to initialize CastContext.

Caused by: java.lang.IllegalAccessException: java.lang.Class<editpackagename.utils.CastOptionsProvider> is not accessible from java.lang.Class<com.google.android.gms.cast.framework.CastContext>
                                                   at java.lang.Class.newInstance(Native Method)
                                                   at com.google.android.gms.cast.framework.CastContext.zzbd(Unknown Source) 
                                                   at com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown Source) 
                                                   at editpackagename.activities.MainActivity.onCreate(MainActivity.java:52) 

That crash happens as soon as I call this in MainActivity:

CastContext castContext = CastContext.getSharedInstance(this);

If I run a debug build, everything works as expected. Using Play Services cast-framework 9.4.0.

like image 696
Paul Ruiz Avatar asked Dec 18 '22 14:12

Paul Ruiz


1 Answers

Made CastOptionsProvider public, and that seems to have taken care of it. Not sure if it's because the class is in a subpackage or not, but looks fine. Documentation doesn't have any access modifiers.

like image 167
Paul Ruiz Avatar answered Jan 12 '23 01:01

Paul Ruiz