Google Cast SDK 中的无效应用程序 ID 崩溃

Invalid application ID Crash in Google Cast SDK

我有一个有效的应用程序 ID,它是从 Google Cast 开发人员那里获得的。
几天前它工作正常,但突然开始崩溃并抛出

Invalid Application ID: Settings

这是我从 google cast 示例应用

中获得的 CastOptionsProvider 代码
public class CastOptionsProvider implements OptionsProvider {

    @Override
    public CastOptions getCastOptions(Context context) {
        NotificationOptions notificationOptions = new NotificationOptions.Builder()
                .setTargetActivityClassName(ExpandedControlsActivity.class.getName())
                .build();
        CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
                .setNotificationOptions(notificationOptions)
                .setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
                .build();

        return new CastOptions.Builder()
                .setReceiverApplicationId(context.getString(R.string.app_id))
                .setCastMediaOptions(mediaOptions)
                .build();
    }

    @Override
    public List<SessionProvider> getAdditionalSessionProviders(Context context) {
        return null;
    }
}

这是我在 Activity 中用来设置演员表的代码

private void setUpCast() {
        mCastStateListener = new CastStateListener() {
            @Override
            public void onCastStateChanged(int newState) {
                if (newState != CastState.NO_DEVICES_AVAILABLE) {
                    showIntroductoryOverlay();
                }
            }
        };

        mCastContext = CastContext.getSharedInstance(this);//App Crashes here
    }

这是我的崩溃日志:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.packagname/com.my.packagname.activities.DashboardActivity}: java.lang.IllegalArgumentException: Invalid application ID: Settings
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2667)
                                                                        at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1494)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                        at android.os.Looper.loop(Looper.java:207)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5776)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
                                                                     Caused by: java.lang.IllegalArgumentException: Invalid application ID: Settings
                                                                        at com.google.android.gms.cast.CastMediaControlIntent.zza(Unknown Source)
                                                                        at com.google.android.gms.cast.CastMediaControlIntent.categoryForCast(Unknown Source)
                                                                        at com.google.android.gms.internal.zzww.zza(Unknown Source)
                                                                        at com.google.android.gms.internal.zzww.<init>(Unknown Source)
                                                                        at com.google.android.gms.cast.framework.CastContext.<init>(Unknown Source)
                                                                        at com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown Source)

我尝试了不同的方法,从控制台生成新的应用程序 ID 并使用那个,但它仍然显示相同的错误

注意:此应用几天前使用相同的代码设置运行良好,但现在崩溃了

为什么会出现这种行为?任何帮助将不胜感激

By cleaning the projects it removed the Invalid Application ID error

是的,资源有时会不同步。当出现以前不存在的奇怪异常时,最好定期清理。