适用于Unity3D的Google Fit Android插件 [英] Google Fit Android plug-in for Unity3D

查看:365
本文介绍了适用于Unity3D的Google Fit Android插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Android开发和Unity相对较新,我正在尝试为Unity3D创建一个Android插件,使用Google fit Sensors API检测步数和距离。我已经将我的插件导出为jar文件,与我的AndroidManifest.xml一起导入Assets / Plugin / Android,当我尝试在手机上构建和运行时出现此错误:

I am relatively new to Android development and Unity and I am trying to create an Android plug-in for Unity3D that detects steps and distance using the Google fit Sensors API. I have already exported my plugin as a jar file, imported in on Assets/Plugin/Android together with my AndroidManifest.xml and when I try to build and run on my phone I get this error:

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.fitness.request.OnDataPointListener" on path: DexPathList[[zip file "/data/app/com.example.me.androidstepcounterplugin-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.me.androidstepcounterplugin-2/lib/arm, /system/fake-libs, /data/app/com.example.me.androidstepcounterplugin-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib]]

我猜Unity无法找到Google Fit库,我将其添加为我的Android Gradle文件的依赖项。有没有办法在Unity中添加它,或者尝试制作aar文件而不是jar更有意义吗?

I am guessing that Unity cannot find the Google Fit library, which I added as a dependency on my Android Gradle file. Is there a way to add this in Unity or would it make more sense to try making an aar file instead of jar?

推荐答案

我可以想到两种可能的情况:

I could think of 2 possible scenarios:


  1. 你运行 proguard 在你的图书馆中使用minify enabled来削减该课程(因为你没有在你的活动中的任何地方引用它)。在这种情况下告诉proguard 保持课程将proguard.properties文件添加到以下行:

  1. You run proguard on your library with "minify enabled" which cuts that class (because you don't reference it anywhere in your activity). In this case tell proguard to keep the class by adding to your proguard.properties file the following line:


-keep classcom.google.android.gms.fitness.request.OnDataPointListener

-keep class "com.google.android.gms.fitness.request.OnDataPointListener"


  • 您正在使用 实现 设置适合依赖项因此不包括在输出中。尝试将相同的依赖项添加到Unity项目中。

  • You are using implementation setting for you Fit dependency therefore not including it in the output. Try adding the same dependency to your Unity project.

    这篇关于适用于Unity3D的Google Fit Android插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆