Android build error: aapt2 unexpected element <provider> found in <manifest> <queries>, Android resource linking failed!!

While attempting to package my Unreal Engine project v4.27.2 for Android ETC2, I encountered an error related to the YodoAds plugin. The build process failed with an error message that included the following: (complete log)
"unexpected element <provider> found in <manifest><queries>".

I discovered that the issue was caused by a syntax error in a cached file from the gradle build. Specifically, the <provider> tag was not enclosed within <application></application> tags.

Unfortunately, I am unable to edit this file directly, as it is a cached file from the gradle build. I have reviewed all the UPL files in my project that influence AndroidManifest.xml, but have been unable to find one that added the incorrect code to the file.

JAVA: 1_8
NDK: r21e
Gradle Version: 6.8.1

Thanks In advance!!

Hi shivansh_pandey2,

We’re encoutering the same error now with UE4.27.2, although ours is caused by a different ad provider’s SDK.

It’s the same issue, but ours is caused by newer versions of the play-services-ads-lite package (we’re using 22.6.0). Apparently ‘“property” cannot be recognized in lower versions of gradle plugin’. ( https://groups.google.com/g/google-admob-ads-sdk/c/IMdomwgNomQ )

Did you ever figure out a solution to this issue?

Thanks,
Matt

Unfortunately I wasn’t able to figure out what was the exact problem but changing the library version solved the problem for me.

We have managed to find a solution which we believe to be working without any problems, although we haven’t released a build with these changes as of yet.
Note, I think this will only be available to you if you’re building from source as you need to modify some engine files.
Essentially we had to upgrade the version of Gradle and the Gradle Plugin that the engine uses.

First we changed UEDeployAndroid.cs located in (Engine\Source\Programs\UnrealBuildTool\Platform\Android) line 25:

private const string ANDROID_TOOLS_BUILD_GRADLE_VERSION = “com.android.tools.build:gradle:4.0.0”;

To

private const string ANDROID_TOOLS_BUILD_GRADLE_VERSION = “com.android.tools.build:gradle:4.2.1”;

Then we changed Engine/Build/Android/Java/gradle/gradle/wrapper/gradle-wrapper.properties line 6:

distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

to:

distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip

Depending on what your third party libraries require, you might need to add a minimumSDKAPI entry into one of your UPL .xml files (which I assume you have and know what you’re doing with them since you’re integrating a third party sdk)

  <!-- New ads SDKs require at least android-33 -->
  <minimumSDKAPI>
		<insertValue value="33"/>
		<insertNewline/>
	</minimumSDKAPI>

That doesn’t need to go in any of the existing sections like <androidManifestUpdates> or anything.
You might also need to add a section in your <buildGradleAdditions> to specify the resolution strategy for androidX:

<buildGradleAdditions>
<insert>
.
.
.
configurations.all {
  resolutionStrategy {
    force 'androidx.core:core:1.8.0'
    force 'androidx.core:core-ktx:1.8.0'
  }
}
</insert>
</buildGradleAdditions>

Cheers,
Matt

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.