Google Fit Android plug-in for Unity3D

可紊 提交于 2019-12-24 18:41:10

问题


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]]

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?


回答1:


I could think of 2 possible scenarios:

  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 class "com.google.android.gms.fitness.request.OnDataPointListener"

  2. 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.



来源:https://stackoverflow.com/questions/47393625/google-fit-android-plug-in-for-unity3d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!