问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/39257813/android-cast-sdk-v3-crashing-in-release-build-only