Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity project as dependency in Gradle

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

like image 782
Michal Kučera Avatar asked Dec 11 '14 21:12

Michal Kučera


People also ask

How do I create a custom Gradle in Unity?

In the Unity Editor, open the Player Settings window (menu: Edit > Project Settings > Player), and select Android. In the Publishing Settings section, enable the Custom Main Gradle Template setting. Unity then generates a default mainTemplate.gradle file in your Project’s Assets/Plugins/Android/ folder.

What is a project dependency in Gradle?

A project dependency is a special form of an execution dependency. It causes the other project to be built first and adds the jar with the classes of the other project to the classpath. It also adds the dependencies of the other project to the classpath. You can trigger a gradle :api:compile.

What is the difference between APK and Gradle in Unity?

When you click Build Unity generates a Gradle project in the specified directory rather than building the APKThe Android Package format output by Unity. An APK is automatically deployed to your device when you select File > Build & Run.

How do I troubleshoot Gradle errors in Unity?

Errors when building with Gradle. If an error occurs during building for Android using Gradle, Unity displays an error dialog box. Click Troubleshoot to open the Gradle troubleshooting Unity documentation in your system’s browser.


Video Answer


2 Answers

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

like image 176
denizen Avatar answered Oct 19 '22 18:10

denizen


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).

like image 37
Scott Barta Avatar answered Oct 19 '22 18:10

Scott Barta