Unity-Technologies / uaal-example

Other
738 stars 235 forks source link

Error on Build, after adding ARCore XR Plugin / ARFoundation package via Unity Package Manager. #16

Open horatiu665 opened 4 years ago

horatiu665 commented 4 years ago

Hi. My goal was to set up an AR scene that will be used in a native app.

First of all I had trouble building and running the native app after following the article https://github.com/Unity-Technologies/uaal-example/blob/master/docs/android.md

but I solved it by making sure target architecture ARMv8 was enabled in Unity Player Settings.

Next, I added the package ARFoundation, and also ARCore XR Plugin, latest preview version 3.1.0-preview-8

Exported from Unity. I got an error that libmain.so is missing, so I had to add ARMv8 and switch to IL2CPP scripting backend, to let it copy the libmain.so into the appropriate folder, it only copied for ARMv7 before that. (I had to do this twice for some reason.... deleting the folder where I exported the android project and exporting again fixed it)

Then I got some other weird errors when building in Android Studio: FAILURE: Build failed with an exception.

Solution was to go in build.gradle (Project: NativeAndroidApp) and change the gradle version to classpath 'com.android.tools.build:gradle:3.1.4' instead of 3.6.1 which is the latest.

Rebuild and it worked.

I may have had to copy a file manually before this worked though, and I can't remember the order when I did it, but here it is: the file OverrideUnityActivity.java from the Unity project, in Plugins/Android/ (weird cause it was marked as an Android native plugin but it was still not copied). had to go in the folder unityLibrary/src/main/java/com/company/product/ as per another closed issue reported here in this repo: https://github.com/Unity-Technologies/uaal-example/issues/14

The issue I'm reporting is that I had to do this stuff manually when I was expecting it to "just work" when I add the ARCore package. Also it's weird it doesn't work with the latest gradle.

Hope this helps someone.

NetDevoGames commented 4 years ago

I was having this issue as well and solved it by adding mavenCentral() repository.

So now my build.gradle (Project: NativeAndroidApp) looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

allprojects {
    buildscript {
        repositories {
            google()
            jcenter()
            mavenCentral()

        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.2'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

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

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I hope this helps :)

jvankooo commented 3 years ago

I was having this issue as well and solved it by adding mavenCentral() repository.

So now my build.gradle (Project: NativeAndroidApp) looks like this:

I hope this helps :)

Adding flatDir to my build.gradle (Project: NativeAndroidApp) solved the issue :

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