- Home /
Use Android plugin with android support library dependency with gradle builds in Unity 5.5
I have an Android plugin which depends in certain android support libraries like design-v7, appcompat-v7, support-v4 etc.
I am using ".aar" files for the dependent android support libraries and my Android plugin uses resources such as layouts, images, styles from these libraries.
When i build the app via gradle option in Unity 5.5, the build fails with errors like : \Temp\StagingArea\gradleOut\design-23.4.0\build\intermediates\bundles\release\res\values\values.xml:65: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Animation.AppCompat.Dialog'.
Is there a way i can tell the gradle build system what my android plugin's dependencies are? Can i add my own build.gradle file for my android plugin specifying the dependencies i need?
Any help is really appreciated. Thanks!
I can't get it to work. See my post for the actual gradle file: http://answers.unity3d.com/questions/1319231/gradle-file-for-unity.html
Answer by liortal · Feb 03, 2017 at 10:54 PM
Starting with Unity 5.5.1p1, you can have a custom gradle build file in your project. This can be done by adding the gradle file under Assets/Plugins/Android/mainTemplate.gradle.
For earlier Unity versions, the only option is to override the default gradle build file that is shipped under the Unity installation folder (not recommended).
Thanks for the reply.
I read through the documentation and could not find an answer for whether we can have a build.gradle file per android plugin so that a plugin can define its own dependencies.
Lets say i have an android plugin "$$anonymous$$yAndroidPlugin" placed under /Assets/Plugins/Android/$$anonymous$$yAndroidPlugin. This plugin depends on appcompat-v7, design libraries. Can i define a "build.gradle" in
/Assets/Plugins/Android/$$anonymous$$yAndroidPlugin folder and specify these dependencies the same way any android project would work? Would Unity gradle build system pick this build.gradle file for building my plugin along with the given dependencies?
Thanks for the help!
i dont thnk this is supported, but i can check.
If it is not supported, that really restricts the 3rd party plugins to use any dependent library. Any 3rd party plugin (depending on some other libraries like android support libs) wont be able to build with the gradle system on Unity since the dependencies cannot be resolved. So the only thing gradle build system enables us to do is override the main application level gradle script and maybe add multi-dex or proguard to it. But there is no way a 3rd party plugin can get an advantage of it. Are there any plans for future to support per plugin custom gradle script?
Grafle dupport is fairly new, so i guess it doesn't cover all use cases.
Even if this option was available, since gradle is not the default build option, plugin developers would have to somehow include dependencies, in case gradle isn't used..