Unity as a library (How to fix: Could not determine the dependencies of task ':app:compileDebugJava)

I am trying to integrate Unity as a library into my native Android project for a project that I am doing. It will employ Unity application to present the items in native Android application in Augmented Reality.

For that, I was following the [https://github.com/Unity-Technologies/uaal-example/blob/b41579464b50edf6682a154f3cbb9e098aa5ba3d/docs/android.md#integrating-unity-as-a-library-into-standard-android-app] to get started.

However, despite following the steps mentioned, I am unable to properly add unityLibrary to my native Android application. Even though the "unityLibrary" module appears in my project's tree as below,

it does not include the respective assets, resources and the classes as it should,

Even though the Gradle syncs when I try to build the project, I get the following error.

"Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve project :unityLibrary.
Required by:
project :app
> No matching configuration of project :unityLibrary was found. The consumer was configured to find a component for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.0.2' but:
- None of the consumable configurations have attributes.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights."

I am mostly new to Unity developing and to programming itself and currently have no idea what I'm doing wrong here. I followed through the steps, setting up the Unity project through build settings and project settings, generating the Gradle file by exporting, copying the contents of build.properties, and inserting the given code snippets in the build.gradle and settings.gradle of the native application. Then finally, I pasted the copied code in the native application's gradle.properties and hit sync.

That's when the unityLibrary module appears in the project without any of its contents. When tried to build the project, it gives the mentioned error.

I am using Unity Editor version 2023.2.3f1, Android Studio Flamingo version 2022.2.1 and Gradle version 8.0.2 (which I updated from 7.1.2 trying to find a solution)

The build.gradle code is below.

apply plugin: 'com.android.application'

dependencies {
    implementation project(':unityLibrary')
    implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.games:games-activity:2.0.0'
    implementation 'androidx.core:core:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

android {
    compileSdkVersion 33

    defaultConfig {
        applicationId "com.unity.mynativeapp"
        namespace "http://schemas.android.com/apk/res-auto"
        minSdkVersion 23
        targetSdkVersion 33
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a"
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

The settings.gradle is as,

pluginManagement {
   repositories {

include ':app'
include ':unityLibrary'
project(':unityLibrary').projectDir=new File('..\\UnityProject\\androidBuild\\unityLibrary')

dependencyResolutionManagement {
   repositories {
       flatDir {
           dirs "${project(':unityLibrary').projectDir}/libs"

The gradle.properties code snippet is as,


org.gradle.jvmargs = -Xmx4096M
org.gradle.parallel = true
unityStreamingAssets =

What am I doing wrong here and how to fix this error?

Are you resolve it?

Make sure you are using Android Studio Iguana | 2023.2.1 or later.
Docs for building uaal-example in Android

well,i think i resolved this problem.
You should do this:
1.In Android:File-New-import Module to import unityLibrary

  • Open settings.gradle file

  • Add a new project pointing to unityLibrary module after the main app module
    include ':unityLibrary'
    project(':unityLibrary').projectDir=new File('..\UnityProject\androidBuild\unityLibrary')

  • And add the following in dependencyResolutionManagement{repositories{ block
    flatDir {
    dirs "${project(':unityLibrary').projectDir}/libs"

  • Open build.gradle(Module: NativeAndroidApp.app) file

  • Add the following in dependencies{ block

implementation project(':unityLibrary')
implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\libs'), include: ['*.jar'])

- In the same file take a look at android{defaultConfig{ndk{ block and make sure abiFilters match the architectures you selected in Unity editor before exporting the project. The filter must match architectures in Unity editor exactly. If Unity exports only ARMv7 architecture, but the filter includes arm64-v8a, the application will crash on ARM64 devices. Check for valid abiFilters values in the official Android documentation.

  • Copy the contents of the gradle.properties file from the exported Unity project root folder to the gradle.properties file in the native application root folder. Note: if you update the Unity project and re-export it again, make sure that the contents of the gradle.properties file in the exported project did not change. If they did - repeat this step.

  • Click Sync Now to do a project sync since Gradle files have been modified
    After this,you may succeed in solving the problem