DevCrew-io / camerakit-flutter

An open-source SDK package for Flutter that provides developers with seamless integration and access to Snapchat's CameraKit features within their Flutter applications.
https://pub.dev/packages/camerakit_flutter
MIT License
14 stars 4 forks source link

The `ARCameraActivity` from the `com.camerakit.camerakit_flutter` package is throwing an error [ java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tryon_camera_kit/com.camerakit.camerakit_flutter.ARCameraActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.] #37

Closed copilot-wmt closed 8 months ago

copilot-wmt commented 8 months ago

Describe the bug The ARCameraActivity from the com.camerakit.camerakit_flutter package is throwing an error when starting, stating "You need to use a Theme.AppCompat theme (or descendant) with this activity." This issue occurs because the activity requires a theme from the Theme.AppCompat family, but the current theme applied to the activity is not compatible.

To Reproduce Steps to reproduce the behavior:

  1. Integrate the com.camerakit.camerakit_flutter package into a Flutter project.
  2. Start the ARCameraActivity from the package.
  3. Observe the error message indicating the incompatible theme.

Expected behavior The ARCameraActivity should start without any theme-related issues.

Additional context

Stack trace Launching lib/main.dart on CPH2467 in debug mode... Running Gradle task 'assembleDebug'... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app-debug.apk... Debug service listening on ws://127.0.0.1:38295/9s1lBuTBe2o=/ws Syncing files to device CPH2467... D/VRIMainActivity: debugCancelDraw cancelDraw=false,count = 304,android.view.ViewRootImpl@2794f00 D/VRIMainActivity: registerCallbacksForSync syncBuffer=false D/VRIMainActivity: Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true syncBuffer=false I/Quality (15818): TaskTrackInfo {"Pkg":com.example.tryon_camera_kit,"Window":com.example.tryon_camera_kit.MainActivity,"Type":1,"Action":10,"Cost":4023,"FV":11,"JC":11-0-0-0-0-0-0-0-9-1-0-1-0-0-0-0-0-0-1-0-4007-3487-524843851-1538,"UITid":15818,"RTid":18139,"PreCount":1} W/Parcel (15818): Expecting binder but got null! D/VRIMainActivity: draw finished. D/VRIMainActivity: onFocusEvent true D/VRIMainActivity: send msg MSG_WINDOW_FOCUS_CHANGED with caller android.view.ViewRootImplExtImpl.markAndDumpWindowFocusChangeMsg:1003 android.view.ViewRootImpl.windowFocusChanged:9827 android.view.ViewRootImpl$WindowInputEventReceiver.onFocusEvent:9540 android.os.MessageQueue.nativePollOnce:-2 android.os.MessageQueue.next:349 android.os.Looper.loopOnce:186 android.os.Looper.loop:351 android.app.ActivityThread.main:8423 java.lang.reflect.Method.invoke:-2 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run:584 com.android.internal.os.ZygoteInit.main:1013 D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged true mUpcomingWindowFocus true mAdded true D/OplusScrollToTopManager(15818): com.example.tryon_camera_kit/com.example.tryon_camera_kit.MainActivity,This DecorView@6b18501[MainActivity] change focus to true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true V/AutofillManager(15818): requestHideFillUi(null): anchor = null D/OplusSystemUINavigationGestureExtImpl(15818): regionString = null D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/OplusInputMethodManagerInternal(15818): get inputMethodManager extension: com.android.internal.view.IInputMethodManager$Stub$Proxy@ae12173 D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true W/ryon_camera_kit(15818): Method com.snap.camerakit.internal.vd3 com.snap.camerakit.internal.mf3.a() failed lock verification and will run slower. W/ryon_camera_kit(15818): Common causes for lock verification issues are non-optimized dex code W/ryon_camera_kit(15818): and incorrect proguard optimizations. W/ryon_camera_kit(15818): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (unsupported,core-platform-api, reflection, allowed) W/ryon_camera_kit(15818): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (unsupported,core-platform-api, reflection, allowed) W/ryon_camera_kit(15818): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (unsupported,core-platform-api, reflection, allowed) D/TrafficStats(15818): tagSocket(124) with statsTag=0xffffffff, statsUid=-1 I/ryon_camera_kit(15818): Compiler allocated 4822KB to compile void com.snap.camerakit.internal.do3.a(java.lang.Object, com.snap.camerakit.internal.e10, com.snap.camerakit.internal.sz1) W/OnBackInvokedCallback(15818): OnBackInvokedCallback is not enabled for the application. W/OnBackInvokedCallback(15818): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest. D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true V/AutofillManager(15818): requestHideFillUi(null): anchor = null D/VRIMainActivity: handleWindowFocusChanged mWindowFocusChanged false mUpcomingWindowFocus true mAdded true D/ScrollOptim SceneManager: updateCurrentActivity: mCurrentActivityName=null, isOptEnable=true, isAnimAheadEnable=true, isFrameInsertEnable=true, InsertNum=1, isEnabledForScrollChanged=false I/ConfigurationController(15818): handleConfigurationChanged: true, config: {1.0 ?mcc?mnc [en_GB] ldltr sw360dp w360dp h720dp 480dpi nrml long hdr widecg port night finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 107 - 1080, 2268) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.288 fontWeightAdjustment=0mThemeChanged= 0, mThemeChangedFlags= 0, mFlipFont= 0, mAccessibleChanged= -1, mUxIconConfig= 3468921665126662177, mMaterialColor= 0, mUserId= 0, mFontUserId= 0, mFontVariationSettings= 226, mFoldingAngle = -1.0, mIconPackName= , mDarkModeBackgroundMaxL= 0.0, mDarkModeDialogBgMaxL= 27.0, mDarkModeForegroundMinL= 100.0, mOplusConfigType= 1, mOplusChangedConfigs= 0, OpSans= 0, mBurmeseFontFlag= 2, mFlag= 0, mPuttDisplayFlag= -1} I/ConfigurationController(15818): , curconfig: {1.0 ?mcc?mnc [en_GB] ldltr sw360dp w360dp h720dp 480dpi nrml long hdr widecg port night finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 107 - 1080, 2268) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.288 fontWeightAdjustment=0mThemeChanged= 0, mThemeChangedFlags= 0, mFlipFont= 0, mAccessibleChanged= -1, mUxIconConfig= 3468921665126662177, mMaterialColor= 0, mUserId= 0, mFontUserId= 0, mFontVariationSettings= 226, mFoldingAngle = -1.0, mIconPackName= , mDarkModeBackgroundMaxL= 0.0, mDarkModeDialogBgMaxL= 27.0, mDarkModeForegroundMinL= 100.0, mOplusConfigType= 1, mOplusChangedConfigs= 0, OpSans= 0, mBurmeseFontFlag= 2, mFlag= 0, mPuttDisplayFlag= -1} I/ConfigurationController(15818): android.app.ActivityThread.handleLaunchActivity:3999 android.app.servertransaction.LaunchActivityItem.execute:111 android.app.servertransaction.TransactionExecutor.executeCallbacks:135 android.app.servertransaction.TransactionExecutor.execute:95 android.app.ActivityThread$H.handleMessage:2470 android.os.Handler.dispatchMessage:106 android.os.Looper.loopOnce:240 android.os.Looper.loop:351 android.app.ActivityThread.main:8423 java.lang.reflect.Method.invoke:-2 D/CameraActivity(15818): Created with parameters: action=com.snap.camerakit.support.CAPTURE_WITH_LENS, apiToken=eyJhbGciOiJIUzI1NiIsImtpZCI6IkNhbnZhc1MyU0hNQUNQcm9kIiwidHlwIjoiSldUIn0.eyJhdWQiOiJjYW52YXMtY2FudmFzYXBpIiwiaXNzIjoiY2FudmFzLXMyc3Rva2VuIiwibmJmIjoxNzA5NzA0MjA4LCJzdWIiOiI1NDYxZDFhYS1mNTFkLTQ0MGUtYTNiOC01ODlhMTI3ZGE5MWR-U1RBR0lOR343Y2QyOWI4My1kNGRlLTRmM2MtOWEyNi1kNTcxODVjOTg5ZDUifQ.Xp8P0VKmQwcNPhZd_i54iaB9Rla-6DrZNBDnDTdE_i0, cameraFacingFront=true, cameraFacingFlipEnabled=true, cameraFacingBasedOnLens=false, cameraFlashConfiguration=Enabled(useRingFlash='false', changeSystemBarColors='false'), cameraAdjustmentsConfiguration=AdjustmentsConfiguration(toneAdjustmentEnabled='true', portraitAdjustmentEnabled='true'), cameraFocusEnabled=true, cameraZoomEnabled=true, lensGroupIds=[cc7a2f87-876e-4903-93c3-a53452bc5644], applyLensById=40369030925, launchData=null, prefetchLensByIdPattern=null, disableIdleState=true, disableLensesCarousel=false, singleLensMode=true, disableCapture=false D/AndroidRuntime(15818): Shutting down VM E/AndroidRuntime(15818): FATAL EXCEPTION: main E/AndroidRuntime(15818): Process: com.example.tryon_camera_kit, PID: 15818 E/AndroidRuntime(15818): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tryon_camera_kit/com.camerakit.camerakit_flutter.ARCameraActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. E/AndroidRuntime(15818): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3872) E/AndroidRuntime(15818): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4014) E/AndroidRuntime(15818): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:111) E/AndroidRuntime(15818): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime(15818): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime(15818): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470) E/AndroidRuntime(15818): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(15818): at android.os.Looper.loopOnce(Looper.java:240) E/AndroidRuntime(15818): at android.os.Looper.loop(Looper.java:351) E/AndroidRuntime(15818): at android.app.ActivityThread.main(ActivityThread.java:8423) E/AndroidRuntime(15818): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(15818): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584) E/AndroidRuntime(15818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) E/AndroidRuntime(15818): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. E/AndroidRuntime(15818): at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:843) E/AndroidRuntime(15818): at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806) E/AndroidRuntime(15818): at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693) E/AndroidRuntime(15818): at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170) E/AndroidRuntime(15818): at com.snap.camerakit.support.app.CameraActivity.onCreate(CameraActivity.kt:907) E/AndroidRuntime(15818): at com.camerakit.camerakit_flutter.ARCameraActivity.onCreate(ARCameraActivity.kt:17) E/AndroidRuntime(15818): at android.app.Activity.performCreate(Activity.java:8422) E/AndroidRuntime(15818): at android.app.Activity.performCreate(Activity.java:8395) E/AndroidRuntime(15818): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1403) E/AndroidRuntime(15818): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3845) E/AndroidRuntime(15818): ... 12 more I/Process (15818): Sending signal. PID: 15818 SIG: 9 Lost connection to device. the Dart compiler exited unexpectedly.

najamsaqib-devcreew commented 8 months ago

Hi @copilot-wmt,

To resolve this issue, Kindly follow the documentation.