Skip to content

Commit e7bcc04

Browse files
author
Stewart Miles
committed
Added support for shared libraries in AARs.
AAR support in Unity varies by version and build system, this patch adds support for shared libraries (.so) files in AARs using a variety of methods: * Unity 4: - Internal (default) build system Shared libraries in the jni folder of AARs are supported but the "jni" folder is ignored when AARs are expanded / exploded so this copies shared libraries to the "lib" folder in the expanded AAR where they're included in the built APK. * Unity <= 5.4 - Internal (default) build system Similar behavior as Unity 4 except only AARs with shared libs or that require variable expansion are exploded. * Unity 5.5 - Internal (default) build system Same behavior as Unity 5.4 - Gradle / Android Studio Settings dialog can disable expansion / explosion of AARs as they're supported natively by the Android Gradle build system. The settings dialog is required to configure this behavior as Unity does not set the applicationId variable in the generated build.gradle. In addition: * Enabled the Android Resolver settings dialog when any platform is selected. * Made it possible to configure the target folder for AARs / exploded AAR directories. Though this turned up a bug in Unity's Android library search process which fails to find libraries in subdirectories so the functionality is disabled at the moment. googlesamples#34 googlesamples#29 BUG=34667843 Change-Id: I843b89ffa614ee2b3508c0a9e0e8a6c025a1668c
1 parent 0e92bec commit e7bcc04

File tree

6 files changed

+519
-169
lines changed

6 files changed

+519
-169
lines changed

source/JarResolverLib/src/Google.JarResolver/Dependency.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ namespace Google.JarResolver
3232
/// </summary>
3333
public class Dependency
3434
{
35+
// TODO(wilkinsonclay): get the extension from the pom file.
36+
internal static string[] Packaging = {
37+
".aar",
38+
".jar",
39+
// This allows users to place an aar inside a Unity project and have Unity
40+
// ignore the file as part of the build process, but still allow the Jar
41+
// Resolver to process the AAR so it can be included in the build.
42+
".srcaar"
43+
};
44+
3545
/// <summary>
3646
/// The version comparator. This comparator results in a descending sort
3747
/// order by version.
@@ -64,8 +74,14 @@ public Dependency(string group, string artifact, string version, string[] packag
6474
PackageIds = packageIds;
6575
this.possibleVersions = new List<string>();
6676
Repositories = repositories;
77+
CreatedBy = System.Environment.StackTrace;
6778
}
6879

80+
/// <summary>
81+
/// Stack trace of the point where this was created.
82+
/// </summary>
83+
internal string CreatedBy { get; private set; }
84+
6985
/// <summary>
7086
/// Gets the group ID
7187
/// </summary>
@@ -153,6 +169,25 @@ public string BestVersionPath
153169
}
154170
}
155171

172+
/// <summary>
173+
/// Get the path to the artifact.
174+
/// </summary>
175+
public string BestVersionArtifact
176+
{
177+
get
178+
{
179+
// TODO(wilkinsonclay): get the extension from the pom file.
180+
string filenameWithoutExtension =
181+
Path.Combine(BestVersionPath, Artifact + "-" + BestVersion);
182+
foreach (string extension in Packaging)
183+
{
184+
string filename = filenameWithoutExtension + extension;
185+
if (File.Exists(filename)) return filename;
186+
}
187+
return null;
188+
}
189+
}
190+
156191
/// <summary>
157192
/// Gets or sets the repository path for this dependency. This is
158193
/// relative to the SDK.

0 commit comments

Comments
 (0)