.AAR libraries are not being imported at all in 4.13

I have dropped in my .aar libraries I need to use with my UE4 android game under \Build\Android\libs, and they are not being included in the built package.

When I create my APK, I notice that they are copied over to the \Intermediate\Android\APK\libs\ folder, so it is apparantly doing something with them, but they’re being ignored.

I’ve spent a few days searching around trying to find any information about how AAR is supported (if at all) by 4.13, and the most I can find is that the Google Play services use AAR, and the undocumented “aar-imports.txt” file.

The contents of aar-imports.txt are as follows:

During the APK build process, the Output Log from UE4 shows this:

My best guess is putting the package names of the libraries in this file to include them as an AAR packages that it will extract, but it doesn’t work. There’s no warning or error either, they just get entirely ignored.

So my questions are: Is AAR actually supported by the engine, or merely hard-coded to support the Google Play services only? - and how do you include AAR libraries in a UE4 android project if they are supported?

aar-imports.txt is read to get the repository locations to search. It expects to find them in package expanded directory structure in any m2repository directory in the path provided. You can also point to the root of a respository with the “repository [path]” directly.

The other lines specify the AAR to use. “com.google.android.gms,play-services-ads,9.2.0” for example will look for com/google/android/gms/play-services-ads/9.2.0 for a play-services-ads-9.2.0.aar and play-services-ads-9.2.0.pom listing the dependencies. It will first look in the android-sdk-windows/extras (ANDROID_HOME = android-sdk-windows) in any m2repository directories, then fall back to the ones in Engine/ThirdParty/Android/extras.

Right now the AAR support is sufficient for Google Play services requirements (we needed a way to reduce the number of methods since the newer versions were getting too big to include everything by default). It does work for other AARs, but I don’t do all the merging steps that may be required for general AAR support. I’m working on switching our build process over to Gradle, but it won’t be for a few releases.

If you don’t want to use AARs you can still place your files in Engine/Build/Android/Java/JavaLibs (or have prebuildCopies section of a UPL file copy it). Look at downloader_library for an example.

Thanks Chris, I will look more into this. We are working on a plugin for Unreal Engine to have developers use our platform’s mobile SDK as an instantiated overlay activity through JNI on Android, and I could not get the .AARs of our libraries to be imported. I may need to try packing them into .JAR or write a custom build process as a workaround until a release has native import support.

Check this thread, we were talking with Chris about how to add .aar for Everyplay plugin. You might find it helpful.
https://forums.unrealengine.com/showthread.php?121564-Everyplay-Plugin

Thanks Makis. I’ve gone through and checked against my project after getting past an unrelated build error. Now I am able to import my AARs, but it fails to build the APK because our SDK has a style dependency on Appcompat v7. If I import the .aar for Appcompat v7, it still doesn’t work.

I also have my APL in my plugin’s directory but the <AARImports> and <repositories> tags aren’t parsed in the UBT, I had to manually update aar_imports.txt in **\4.13\Engine\Build\Android\Java**.

Since AndroidManifest xml merging is disabled right now would that be a cause of that?

I’m not sure what repositories section you are referring to, it is just AARImports something like this:


<AARImports>
	<insertValue value="repositories $S(PluginDir)/extras" />
	<insertNewline/>
	<insertValue value="com.coolcompany.neatlibrary,superusefulstuff,1.2.0" />
	<insertNewline/>
</AARImports>

Where it would look for m2repository directories in extras. Or, can just use repository for path to one directory instead of it searching.

Right, sorry I’m not sure why I said <repositories>, it is exactly like that in my MyModule_APL.xml file within \Plugins\MyPlugin\Source\MyModule.

Does it need to be MyModule_APL.xml or MyModule_UPL.xml in 4.13? I’ve tried both but neither adds to the aar_imports.txt when doing an APK build, that’s why I had to manually add to the Engine’s aar_imports.txt.

Even though the output log shows my AAR’s being imported and extracted, it won’t pick up the layout styles used in our SDK from Appcompat v7 even if explicitly included before my SDK.

I also tried putting a <dependency> in the .pom for our SDK .aar in regards to the appcompat v7 style as briefly mentioned in Everyplay’s forum thread, but still no go. It can’t find the appcompat resource styles when building and fails.

SDK’s .pom:

After doing some more extensive research on this, I’ve figured out how the APL/UPL xml is included, as well as its language syntax thanks to the commented source here.

Now I’ve got my problem narrowed down to an odd .jar inclusion in the build tool.

Specifically this part:

**NVPACK\android-sdk-windows\extras\android\m2repository\com\android\support\support-v4\21.0.3\ **specifically has a .aar, .pom, -javadoc.jar, and -sources.jar. I’m assuming what it’s looking for is the -sources.jar, but if I rename that to support-v4-21.0.3.jar (without ‘-sources’), it copies that, then has a conflict with a duplicate jar that I assume it created from the original AAR.

Edit: I’ve also since made sure to clear the project and plugin’s respective Binaries, Build and Intermediate folders as well as deleting and regenerating the visual studio solution to ensure there’s nothing old leftover from build attempts. No further progress.

Seems after removing my libraries from Engine/Build/Android/Java/JavaLibs it doesn’t have a duplicate .jar issue, now I’m back to where it just can’t find the appcompat style (and others, as listed in the log output above) which is even copied over during the build process at \Intermediate\Android\APK\JavaLibs\appcompat-v7-23.2.0\res\values\values.xml, yet it keeps complaining that is missing. I really don’t know what to do anymore after spending weeks trying to get this to build.

Try merging the style.xml manually with the one in Engine/Build/Android/Java/res/values and see if that works.

Same errors, no change.

&stc=1

Are you allowed to give a link of the sdk’s .aar files and the support v7 .aar, so i can give it a try?

@Auron#5260 I had a different problem days ago, by chance I saw your topic and realized that this line was happening in my build oftenly before PERFORMING FINAL APK PACKAGE OPERATION



UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.AddRepositories: Added repository: C:\Program Files (x86)\Epic Games\4.13\Engine\Source\ThirdParty\Android\extras\android\m2repository
UATHelper: Packaging (Android (ETC2)): UEDeployAndroid.ExtractAARAndJARFiles: AARImports: com.google.android.gms, play-services-ads, 9.2.0
UATHelper: Packaging (Android (ETC2)): UEDeployAndroid.ExtractAARAndJARFiles: AARImports: com.google.android.gms, play-services-auth, 9.2.0
UATHelper: Packaging (Android (ETC2)): UEDeployAndroid.ExtractAARAndJARFiles: AARImports: com.google.android.gms, play-services-games, 9.2.0
UATHelper: Packaging (Android (ETC2)): UEDeployAndroid.ExtractAARAndJARFiles: AARImports: com.google.android.gms, play-services-nearby, 9.2.0
UATHelper: Packaging (Android (ETC2)): UEDeployAndroid.ExtractAARAndJARFiles: AARImports: com.google.android.gms, play-services-plus, 9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-ads-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-ads-lite-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-basement-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR support-v4-23.0.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-base-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-tasks-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-clearcut-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-gass-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-auth-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-auth-base-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-games-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-drive-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-nearby-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.ExtractAARs: Extracting AAR play-services-plus-9.2.0
UATHelper: Packaging (Android (ETC2)): AndroidAARHandler.CopyJARs: Copying JAR support-annotations-23.0.0.jar


Now that I solved it don’t appears anymore. I’m not an expert but I know what it feels getting days to solve a problem and maybe tis can help you, idk, just a hint. :wink:
Did you update CodeWorks? if u did, uninstall it and install 1R4u2.

Are you using source? if you are my suggestion would be
-delete the folders: Binaries, Build, Intermediate, DerivedDataCache
-generate the project file and build your project again

that fixed my problem. My problem was different than yours. it was that some libraries was missing in the APK Final Operation step, I thought it was ANT problem, or code works, but after I deleted those folders and build it again, it worked and those extracting lines are not appearing anymore.

good luck :slight_smile:

Just sent you a private message about that. Sorry for the delay, just came back from Thanksgiving break and moving homes.

Spoke with you on the Discord mobile channel about that. It’s not a CodeWorks / Android SDK issue and I’ve been regenerating my project every now and then already. Tried packaging the APK with 4.14 Github Source, didn’t help at all. In my AAR’s .pom file I list the appcompat v7 as a dependency and it gets exploded into the \Intermediate\ folder during the packaging process, but it seems its resources are being ignored from UBT and/or ANT.

Check your private messages.

Thanks to email communication with Makis and doing some thorough back and forth work with my plugin, I’ve managed to get our .AAR SDK imported and through JNI calls initialized on top of the UE4 GameActivity during runtime on-device. Thank you again Makis, and thanks Chris Babcock for support on this matter.

I will try to find time to write up a detailed article for other developers on how to import and use a .AAR compiled library in a UE4.13+ project until UE4 has gradle and merge support.

What I had to do in this particular case following the last forum posts:

Example: *error: Error: No resource found that matches the given name (at ‘textAppearance’ with value ‘@style/Base.TextAppearance.AppCompat.Subhead’).*Solution: I had to find the Base.TextAppearance.AppCompat.SubHead value from it appcompat v7’s values.xml and copy it into my .AAR’s /res/values.xml as well as any parent or dimension values it depended on, plus all other styles and their recursive values. Once I did that, went through the proper JNI calls, and added my SDK’s AndroidManifest.xml activities into the plugin’s UPL definition, all went smoothly.

**** PROTIP: If you need to get the UE4 GameActivity context in JNI to initiate an overlay on top of your game (or whatever else you’d need the game activity context for), you’d do so like this:

Cheers and look forward to .AAR and Gradle build support being fully integrated in the near future releases!