0

I had a CastClassException when trying to launch a VideoRecorderActivity. Here is how I'm doing so :

mTempVideoFile = new File(getContext().getFilesDir(), DateTime.now().getMillis()+"videoAndroid.mp4");

Intent takeVideoIntent=new VideoRecorderActivity.IntentBuilder(getContext())
            .quality(VideoRecorderActivity.Quality.LOW)
            .durationLimit(60000)
            .to(mTempVideoFile)
            .debug()
            .build();

startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO);

the stacktrace :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m360learning.android/com.commonsware.cwac.cam2.VideoRecorderActivity}: java.lang.ClassCastException: java.lang.Boolean cannot be cast to com.commonsware.cwac.cam2.ZoomStyle
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                       at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:148)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                    Caused by: java.lang.ClassCastException: java.lang.Boolean cannot be cast to com.commonsware.cwac.cam2.ZoomStyle
                                                       at com.commonsware.cwac.cam2.CameraFragment.getZoomStyle(CameraFragment.java:452)
                                                       at com.commonsware.cwac.cam2.CameraFragment.onCreateView(CameraFragment.java:203)
                                                       at android.app.Fragment.performCreateView(Fragment.java:2220)
                                                       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
                                                       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
                                                       at android.app.BackStackRecord.run(BackStackRecord.java:793)
                                                       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
                                                       at android.app.FragmentController.execPendingActions(FragmentController.java:325)
                                                       at android.app.Activity.performStart(Activity.java:6267)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                       at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:148) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Also I skipConfirm() is in the documentation but is not recognized in my code which make me think maybe I have the wrong version of the library.

I took from this maven repo "https://s3.amazonaws.com/repo.commonsware.com", this version 'com.commonsware.cwac:cam2:0.5.+'

Thanks !

Renaud Favier
  • 1,645
  • 1
  • 17
  • 33

1 Answers1

1

I had a CastClassException when trying to launch a VideoRecorderActivity

Yup, that's a bug. I'll fix that shortly.

Also I skipConfirm() is in the documentation but is not recognized in my code which make me think maybe I have the wrong version of the library.

No, that's a documentation bug, as there is only a confirmation screen on still pictures, not videos.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Okay, I'll wait for the update. Please notify me here when It's corrected. I looked at the code, it seems that the error comes from the line 130 of ```CameraFragment```, I think you should just remove this line and it should work fine, or replacing it with ```args.putSerializable("zoomStyle", ZoomStyle.NONE);``` to be more explicit – Renaud Favier Feb 23 '16 at 17:58
  • @RenaudFavier: Correct, the line needed to be removed. Originally, I had it as a boolean, then switch to the `ZoomStyle` enum. However, I failed to check the video-recording path, and therefore didn't catch that I still had it as a `boolean` there. v0.5.1 is released with this fix. However, Gradle has a tendency to only check for wildcard version updates once a day. You may need to update your dependency to be specifically on `0.5.1` instead of `0.5.+` to pull down the updated artifact. – CommonsWare Feb 23 '16 at 18:02