简体   繁体   中英

Google Fit Android plug-in for Unity3D

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM