-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[mono] Add Android app sample using mono runtime #3944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
// it's not part of the BCL but runtime needs it for native-to-managed callbacks in AOT | ||
// To be replaced with NativeCallableAttribute | ||
public class MonoPInvokeCallbackAttribute : Attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can get rid of it using Function Pointers for callbacks actually but I'm not sure, last time I checked - callbacks still needed it on Mono.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it's not needed for JIT (which is the only option for Android atm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works after removing this block as well as the attributes. Does this still qualify as showing how the embedded mono runtime allows for C# and C to call each other with just the function pointers and Dllimport
?
JNIEnv* jniEnv = GetJniEnv(); | ||
|
||
jclass mainActivity = (*jniEnv)->FindClass (jniEnv, "net/dot/MainActivity"); | ||
jmethodID getAge = (*jniEnv)->GetStaticMethodID(jniEnv, mainActivity, "getAge", "()I"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: FindClass won't work for Activity in non-UI thread afair.
e4873d0
to
40cb7ff
Compare
@adegeo Can the check run
|
7b7fcb2
to
fc1cab5
Compare
6ec2dc0
to
7eca2bb
Compare
7eca2bb
to
664557b
Compare
I just updated the script to allow custom commands. Add the {
"host": "custom",
"command": "dotnet publish \"$projectFile\""
} I'm not sure if you need to pull in the latest from master or not. |
Thanks @adegeo! I think the problems for these mono samples was the github actions runner being |
Summary
This PR looks to port over the Android sample from
dotnet/runtime
to highlight the concept of building applications on top of the mono runtime.There are several dependencies such as Android SDK, Android NDK, an Android emulator required to run the sample with
dotnet publish
.The sample will depend on a NuGet Package containing the files that build the app and embed the mono runtime into the app, and the code that will build that package can be found here dotnet/runtime#43216
Currently, it is rebased off of #3931 and will be updated after the iOS sample is merged.