UE4.20 AAR imports

I’ve been working with arcore with ue4.19 and it was ok, but there are some issues with 4.20 version. The problem is google play service dependencies. Gradle complains about aar imports:

Could not find method implementation() for arguments [com.google.android.gms:play-services-auth:11.8.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

These includes can be found at Engine/Build/Android/Java/aar-imports.txt, so, I guess, they should be there(I tried deleting them altogether, that didn’t work). UE4.19 has the same structure but the version was 11.0.4 and that made me wonder if I have the proper libraries installed(I have lvl 25 and 24 api from codeworks).
If anyone has an idea of what might be wrong please let me know.

There is a prebuild build.gradle file in UE\Engine\Build\Android\Java and it UE4.20 there was absent include for google services, so I added that. Also changed the version in aar-imports.txt to use the latest and ensured all my support libraries have the same version across different plugins.

MrMcKvarz, could you post content of the relevant files that you changed to fix this, I’m struggling with the same issue. I guess it doesn’t help that I’m not an expert in graddle :slight_smile:

Sure, the way I discovered what to do was opening generated project in intermediate by Android Studio, and there were some hints about gradle not syncing. I changed all com.google.android.gms to use the latest version, so my aar.txt import looks something like:

repositories $(ANDROID_HOME)/extras
repositories $(ENGINEDIR)/Source/ThirdParty/Android/extras
com.google.android.gms,play-services-auth,+
com.google.android.gms,play-services-games,+
com.google.android.gms,play-services-nearby,+
com.google.android.gms,play-services-plus,+

I think it could cause issues if you have a specific API level in mind, in that case, you just need to be sure they all are using the same version.

I have used com.android.support:appcompat for creating a custom activity. You also need to make sure all your com.android.support includes are using the same version(I used 24.2.1 version, so the full include was compile(‘com.android.support:appcompat-v7:24.2.1’)).

In ue4.20 there missing some includes in build.gradle, so I added them too:

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

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
		classpath 'com.google.gms:google-services:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    apply from: 'buildscriptAdditions.gradle', to: buildscript
}

apply from: 'baseBuildAdditions.gradle'

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

Eventually, the solution on my side was to copy Build\Android\Java\gradle\build.gradle from Epic’s binary distribution of UE4.20.2. I’m using Oculus fork of the same version and the file is different in few places, though I haven’t investigated which of these actually helped.

Hi all. You guys seem to know more than I do, and I’m currently facing a similar situation when building from with Unreal Engine 4.22.2 from Epic’s Oculus Quest Git repository. All goes well until the end when i get a gradle error, or an android.bat error. In this case, I opened the project and found that the gradle file below is not being found. Any idea why?

This is my first android project. Some suggested reinstalling android, which I did. I also reinstalled Unreal, and even Windows. I also did a new VR default project. I keep getting the same error. Some help would be appreciated. I’ve been trying to solve this for about 2 weeks.

Hi, can you build an empty project, without vr or other complex stuff with this custom engine?