Reputation: 582
I'm writing Unity Android application which uses Android native plugin. This plugin implements background service which tracks user location and sends push notification when users enters some points of map.
I build this service as a standalone .jar
package and put in Assets/Plugins/Android
folder. But when I build it, I cannot access UnityPlayer
to use UnitySendMessage
.
So how can I run UnitySendMessage
method from my service? Thanks for response.
Upvotes: 2
Views: 1017
Reputation: 1093
You need to import a dependency in your Android Project, which is a library of Unity that contains UnityPlayer class.
This is located in the folder :
Windows: Unity\Editor\Data\PlaybackEngines\androidplayer\release\bin
OS X: Applications/Unity/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Classes/
And the file is named classes.jar (I strongly recommend to change the name for something recognizable).
After that, you need to tell Gradle that you don't want this jar file to be added in your jar file (unity will automatically provide it). So you ad that in your build.gradle dependancies : provided files('./libs/UnityPlayer.jar')
Finally, you just need to import the library in your java file : import com.unity3d.player.UnityPlayer;
Upvotes: 4