Skip to content

Commit

Permalink
Merge branch 'main' into HelloWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpeppers committed Jan 31, 2024
2 parents a48fb0e + 8646605 commit 6fa47a6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,20 @@ A breakdown of the files inside:

`libdotnet.so` is ~1.9MB, and `libSkiaSharp.so` is ~8.5MB!

If we reduce this to a "Hello World" example:

* `hello.apk` is ~561 KB!
* `libdotnet.so` (uncompressed) is ~1.1 MB

## "Hello World" Example

See the [HelloWorld](https://github.com/jonathanpeppers/Android-NativeAOT/tree/HelloWorld) branch.

I had this managed code:

```csharp
[UnmanagedCallersOnly(EntryPoint = "ManagedAdd")]
public static int ManagedAdd(int x, int y)
{
Console.WriteLine($"ManagedAdd({x}, {y})");
return x + y;
}
public static int ManagedAdd(int x, int y) => x + y;
```

I created a C++ Android project using NativeActivity, and I called the managed
Expand All @@ -97,7 +100,8 @@ __android_log_print (ANDROID_LOG_INFO, TAG, "ManagedAdd(1, 2) returned: %i", res
Results in the message:
```log
01-29 10:41:04.363 11016 11042 I Native : ManagedAdd(1, 2) returned: 3
01-31 11:42:44.545 28239 28259 I NATIVE : Entering android_main
01-31 11:42:44.550 28239 28259 I NATIVE : ManagedAdd(1, 2) returned: 3
```

See [DotNet/README.md](DotNet/README.md) on how to build `libdotnet.so`.
Expand Down

0 comments on commit 6fa47a6

Please sign in to comment.