Skip to content

Commit 980ff25

Browse files
committed
Added android support for lib loader
1 parent 4406197 commit 980ff25

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

HexaGen.Runtime/HexaGen.Runtime.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net7.0;netstandard2.0;netstandard2.1;net472</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net7.0;netstandard2.0;netstandard2.1;net472;net8.0-android</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -11,7 +11,7 @@
1111
<RepositoryUrl>https://github.com/JunaMeinhold/HexaGen</RepositoryUrl>
1212

1313
<AssemblyVersion>1.1.0</AssemblyVersion>
14-
<PackageVersion>1.1.7</PackageVersion>
14+
<PackageVersion>1.1.8</PackageVersion>
1515
<Description>The C Runtime for all C Wrappers generated with the HexaGen Code Generator.</Description>
1616
<Authors>Juna Meinhold</Authors>
1717
<PackageProjectUrl>https://github.com/JunaMeinhold/HexaGen</PackageProjectUrl>
@@ -36,4 +36,8 @@
3636
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net472'">
3737
<PackageReference Include="System.Memory" Version="4.5.5" />
3838
</ItemGroup>
39+
40+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
41+
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.13.1.3" />
42+
</ItemGroup>
3943
</Project>

HexaGen.Runtime/LibraryLoader.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
using HexaGen.Runtime;
99
#endif
1010

11+
#if ANDROID
12+
using Android.Content.PM;
13+
#endif
14+
1115
public enum TargetPlatform
1216
{
1317
Unknown = 0,
@@ -181,7 +185,16 @@ public static nint LoadLibrary()
181185

182186
private static string GetNativeAssemblyPath(string osPlatform, string architecture, string libraryName)
183187
{
184-
var assemblyLocation = AppContext.BaseDirectory;
188+
#if ANDROID
189+
// Get the application info
190+
ApplicationInfo appInfo = Application.Context.ApplicationInfo!;
191+
192+
// Get the native library directory path
193+
string assemblyLocation = appInfo.NativeLibraryDir!;
194+
195+
#else
196+
string assemblyLocation = AppContext.BaseDirectory;
197+
#endif
185198

186199
var paths = new[]
187200
{

0 commit comments

Comments
 (0)