Heads up! We're sunsetting this forum to streamline our community space.

join us on Discord for support, updates, and all things Snap AR! See you there!
Sign up for our live Camera Kit office hour on July 17 @ 9:30am (PT) / 4:30pm (GMT)

Camera Kit Unity Sample - Crash on Android version 11 and 14

Pico Alta
Pico Alta Posts: 22 🔥
edited March 20 in General #1

Hello there,

I am very happy to see that the camera-kit-unity-sample repository was released, because it takes a lot of guesswork out of making a Unity app with Camera kit.

I managed to get the Android code working on a Galaxy A52 (Android version 13), but on the same Android studio project the same build crashes on my Pixel Pro 8 (Android version 14) and my old OnePlus 6 (Android version 11).

I will post the crash message below this post

I am using the following setup:

Unity version 2022.1.23f1
Android Studio Flamingo 2022.1.1 Patch 2
When opening the project, I selected use embedded Android SDK (so the Unity's Android SDK version is targeted)

Steps:
In Unity:
I followed the steps in the readme.

In Android studio:
Performed steps in readme, and then

  • Clicked file -> sync project with gradle files
  • Clicked Build -> Clean project
  • Clicked Build -> Rebuild project
  • Attach Galaxy A52, select device and press play, notice that project runs fine
  • Attach Oneplus 6, select device and press play, notice that project crashes on launch.

Crash output:

FATAL EXCEPTION: main
Process: com.snap.camerakitsamples.unity.android, PID: 14679
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.snap.camerakitsamples.unity.android/com.snap.camerakitsamples.unity.android.MainUnityActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3616)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
at com.snap.camerakitsamples.unity.android.MainUnityActivity.onCreate(MainUnityActivity.kt:55)
at android.app.Activity.performCreate(Activity.java:8006)
at android.app.Activity.performCreate(Activity.java:7990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3589)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)

Best Answer

Answers

  • stevenxu
    stevenxu Posts: 612 👻

    @Pico Alta Glad to hear this Unity sample is useful for you! Confirming I've created a ticket for our eng to look into this. Hang tight!

This discussion has been closed.

Categories