I created an Android Unity plugin (.aar file) that provides some custom positioning data for my Unity game. In my Unity script, I use
var x = customClass.CallStatic<float>("getHeadX");
To get location data. This method is called for each frame to obtain updated data (polling method), which makes it inefficient. Instead, I decided to call the C # method in my Unity script from my java code (plugin) when the updated data is ready. For this, in my java plugin I wrote
import com.unity3d.player.UnityPlayer;
...
UnityPlayer.UnitySendMessage("Manager", // gameObject name
"PluginCallback", // this is a callback in C
"Hello from android plugin"); // msg which is not needed actually
However, the compiler complained that the com.unity3d.player.UnityPlayer package did not exist. So I copied the classes.jar file from
C: \ Program Files (X86) \ Unity \ Editor \ Data \ PlaybackEngines \ AndroidPlayer \ Variations \ mono \ Release \ Classes \ classes.jar
to the "libs" folder of my Android plugin project. I built it successfully and copied the generated .aar file (mylibrary-release.aar) to the Assets \ Plugins \ Android folder of my Unity project.
When I create a Unity project (using the "internal" build system), it gives me this error:
IOException: Failed to move the file / directory from 'Temp / StagingArea \ android-libraries \ mylibrary-release \ classes.jar' to 'Temp / StagingArea \ android library \ MyLibrary release \ LIES \ classes.jar . UnityEditor.Android.PostProcessor.Tasks.ProcessAAR.Execute ...
- , classes.jar classes.jar(- ). unity_classes.jar, , :
CommandInvokationFailure: dex.C:/Program Files/Java/jdk1.8.0_102\bin\java.exe -Xmx2048M Dcom.android.sdkmanager.toolsdir = "C: \/Users/kamran.shamloo/AppData/Local/Android/Sdk " -Dfile.encoding = UTF8 -jar "C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar"
stderr [ : java.lang.IllegalArgumentException: : Lbitter/jnibridge/JNIBridge; : java.lang.IllegalArgumentException: : Lbitter/jnibridge/JNIBridge $; : java.lang.IllegalArgumentException: : Lcom/Unity3D//NativeLoader; : java.lang.IllegalArgumentException: : Lcom/Unity3D//ReflectionHelper; : java.lang.IllegalArgumentException: : Lcom/Unity3D//ReflectionHelper $1; : java.lang.IllegalArgumentException: : Lcom/Unity3D//ReflectionHelper $; : java.lang.IllegalArgumentException: : Lcom/Unity3D//UnityPlayer; : java.lang.IllegalArgumentException: : Lcom/Unity3D//UnityPlayer $1; : java.lang.IllegalArgumentException: : Lcom/Unity3D//UnityPlayer $10;...