Connecting to Parrot Anafi drone from Unity

Hello everyone,

I’m try to connect my drone to my Unity project (I’m making custom UI interface) After doing some readings, I built a small module in Android Studio and made connection with my unity project (sent and receieved basic messeges). I tried the example project, seperatly, and it worked. Then I proceeded to include the relevant libraries in my module and that’s where the problems started.

Even thought I included in the dependencies

// GroundSdk dependencies
implementation ('com.parrot.drone.groundsdk:groundsdk:7.0.1'){transitive(true)}
runtimeOnly ('com.parrot.drone.groundsdk:arsdkengine:7.0.1'){transitive(true)}

When I try to obtain session with

mGroundSdk = ManagedGroundSdk.obtainSession(UnityPlayer.currentActivity);

My app crashes. I can see the problem in Android Studio’s Logcat

2022-02-14 12:50:18.120 17879-17879/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.asgard.UnityInterface, PID: 17879
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/parrot/drone/groundsdk/ManagedGroundSdk;
at com.asgard.unityinterface.AnafiConnector.onCreate(AnafiConnector.java:62)
at android.app.Activity.performCreate(Activity.java:8159)
at android.app.Activity.performCreate(Activity.java:8131)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3512)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3699)
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:2135)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8056)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Caused by: java.lang.ClassNotFoundException: com.parrot.drone.groundsdk.ManagedGroundSdk
at com.asgard.unityinterface.AnafiConnector.onCreate(AnafiConnector.java:62)
at android.app.Activity.performCreate(Activity.java:8159)
at android.app.Activity.performCreate(Activity.java:8131)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3512)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3699)
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:2135)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8056)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)

After doing some more research I found out the my dependencies weren’t included in the AAR module (?)

Is there a way to include the GroundSDK in my AAR? How do I do this manually?

Thanks in advance!

To people from the future facing the same problem,
The answer is to check the “custom main gradle” option in
Player Settings => Android => Build
and add the references there

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.