Home » Android » android – Unity project as dependency in Gradle

android – Unity project as dependency in Gradle

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am trying to import an unity3d project to my android project as a module. All is okay, gradle sync finish without error, but when i add unity project as dependency to my project and run gradle sync then it says:

Error:Dependency myapplication:unityproject:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: /Users/michal/Documents/Projects/myapplication/unityproject/build/outputs/apk/unityproject-release-unsigned.apk

I tried google it, but with no luck… Thanks a lot for any tips…
I am using Android Studio (if it helps)

I can build and run standalone unity3d project on mobile device, problem is only when i am trying to add it as module (dependency) to another project

How to&Answers:

In Android Studio, you can’t depend on an Android Application module (which has an APK as its output). You can only depend on Java libraries (which compile to JAR) or Android Library modules (which compile to AAR).

Answer:

In your library’s gradle.build, Change the line apply plugin: com.android.application to apply plugin: com.android.library and remove the setApplicationId

Answer:

I’m an android noob, but I was able to import a simple Unity app into Android Studio by checking “Google Android Project” in the export dialog.

Deets:
* Unity 4.6.1
* Android Studio 1.0
(note if you download A.S. “1.0”, you still need to do a software update a couple times to really get it)