从 Unity 连接到 Parrot Anafi 无人机
Connecting to Parrot Anafi drone from Unity
我正在尝试将我的无人机连接到我的 Unity 项目(我正在制作自定义 UI 界面)
在做了一些阅读之后,我在 Android Studio 中构建了一个小模块并与我的统一项目建立了连接(发送和接收基本消息)。
我分别尝试了 Anafi example project,它成功了。
然后我开始在我的模块中包含相关的库,这就是问题开始的地方。
甚至以为我包含在依赖项中
// GroundSdk dependencies
implementation ('com.parrot.drone.groundsdk:groundsdk:7.0.1'){transitive(true)}
runtimeOnly ('com.parrot.drone.groundsdk:arsdkengine:7.0.1'){transitive(true)}
当我尝试获取与
的会话时
mGroundSdk = ManagedGroundSdk.obtainSession(UnityPlayer.currentActivity);
我的应用程序崩溃了。我可以在 Android Studio 的 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)
经过更多研究后,我发现我的依赖项未包含在 AAR 模块中 (?)
有没有办法在我的 AAR 中包含 GroundSDK?我该如何手动执行此操作?
提前致谢!
未来面临同样问题的人们,
答案是勾选“custom main gradle”选项
播放器设置 => Android => 构建
并在那里添加引用
我正在尝试将我的无人机连接到我的 Unity 项目(我正在制作自定义 UI 界面) 在做了一些阅读之后,我在 Android Studio 中构建了一个小模块并与我的统一项目建立了连接(发送和接收基本消息)。 我分别尝试了 Anafi example project,它成功了。 然后我开始在我的模块中包含相关的库,这就是问题开始的地方。
甚至以为我包含在依赖项中
// GroundSdk dependencies
implementation ('com.parrot.drone.groundsdk:groundsdk:7.0.1'){transitive(true)}
runtimeOnly ('com.parrot.drone.groundsdk:arsdkengine:7.0.1'){transitive(true)}
当我尝试获取与
的会话时mGroundSdk = ManagedGroundSdk.obtainSession(UnityPlayer.currentActivity);
我的应用程序崩溃了。我可以在 Android Studio 的 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)
经过更多研究后,我发现我的依赖项未包含在 AAR 模块中 (?)
有没有办法在我的 AAR 中包含 GroundSDK?我该如何手动执行此操作?
提前致谢!
未来面临同样问题的人们, 答案是勾选“custom main gradle”选项 播放器设置 => Android => 构建 并在那里添加引用