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://blog.nraboy.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 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
.
- Copy
SampleDependencies.cs
from the jar resolver into an Editor folder
- Rename the file and class to be something more useful, eg. "MyDependencies.cs"
- Uncomment the body of the class
- Add your dependency:
svcSupport.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.
I have, so far, not found a way to make an Android Library Project with external library dependencies using Android Studio. I ended up using Eclipse and it worked like a charm so, if anyone else out there is struggling with this, at least for now, I'd recommend you to use Eclipse instead (this is coming from someone who doesn't really like Eclipse that much).
I won't mark this as a correct answer since it really doesn't answer the original question. So if anyone finds an answer to my original question I'd appreciate it if you could answer, otherwise, I'll leave this one here to help others who might want to create a plugin using external dependencies with Eclipse.