I recently created an Android Studio project using estimote beacons. This requires that the build.gradle be modified so that it can access the estimote sdk. I created the project and it works great. I also created a simple android plugin to show a Toast message from Unity (instructions found here: https://www.thepolyglotdeveloper.com/2014/06/creating-an-android-java-plugin-for-unity3d/).
Now, because we use unity at my job to create apps, now I need to create a plugin for the beacons to be used inside unity, my question is basically, how do I add the gradle dependencies (compile 'com.estimote:sdk:0.9.7@aar') into the library project of Android (a library project, for what I saw, generates no gradle files) and/or into unity so that I can use the beacon code in unity?
I use unity 2017.4.24f1 lts
unity editor > player settings > publishing settings > build > custom gradle template,
it will generate Assets/Plugin/Android/maintemplate.gradle
edit above template, add android dependencies like regular android project
I recommend you take a look at the Unity Jar Resolver project by Google. It does something similar to what adding dependencies in Gradle does. Once you have it integrated, you would then create a class based on SampleDependencies.cs
.
SampleDependencies.cs
from the jar resolver into an Editor foldersvcSupport.DependOn("com.estimote", "sdk", "0.9.7");
By default, the Jar Resolver will run automatically, copying the .aar file into the project. You can turn this off and just do it manually in "Assets > Google Play Services > Settings"
Note: It's called Google Play Services because it's used to import Google Play Services and Firebase .aar
files into Unity projects. It should work with other dependencies, but you may need to finagle with some internal code or file system placement if it can't find the source .aar file
. From what I can tell, it looks for them in ANDROID_HOME/extras/*/m2respository
directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With