Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8469657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:17:20+00:00 2026-06-10T16:17:20+00:00

I have created a fairly simple Activity in Mono for Android project: [Activity(Label =

  • 0

I have created a fairly simple Activity in Mono for Android project:

[Activity(Label = "AndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
    private string value = "intitial";

    [Export]
    public string GetString()
    {
        return value;
    }

    [Export]
    public void SetString(string newValue)
    {
        value = newValue;
    }
}

The activity should only serve as a proof-of-concept, hence its simplicity. Now, I’d like to be able to call the method GetString() from the “normal”, Java-based Android application.

In Xamarin’s docs, I’ve read about Java to Managed interop, which seems to be exactly what I’m looking for. If I understand it correctly, when Mono for Android app compiles, it generates Java classes that are referred to as Android Callable Wrappers (ACW). I should be then able to call methods on these ACWs from Java-based Android application.

The question is, how exactly do I reference compiled Mono for Android application (the apk file) from the Java-based Android app?

This is where I’m now stuck and was unable to find any concrete examples. There are similar questions here on SO (this one and this one) and some blogposts, but they just boil down to “use ACWs”. But how exactly? Maybe I am missing something obvious here, being no Android guy.

What I’ve tried is to dynamically load the dex file that I yanked from my Mono for Android apk. I’ve simply put it on the storage card and then tried to use DexClassLoader from Java-based Android app to load it (I’ve followed this blog post). The ACW class was found, but when I tried to create its instance, I got the following error:

No implementation found for native Lmno/android/Runtime;.register (Ljava/lang/String;Ljava/lang/Class;Ljava/lang/String;)

I suppose that I have to somehow include Mono for Android runtime to the Java-based app, but I have no idea how.

EDIT:
This is the code I am trying to load the dex with:

DexClassLoader cl = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
    optimizedDexOutputPath.getAbsolutePath(),
    null,
    getClassLoader());

try {
    Class<?> classActivity1 = cl.loadClass("androidapplication1.Activity1");

    // the following line throws the exception
    Object a = classActivity1.newInstance();

    Method getStringMethod = classActivity1.getMethod("GetString");
    Object result = getStringMethod.invoke(angel);

    result = null;
} catch (Exception e) {
    e.printStackTrace();
}

EDIT2:
I am now reading here that it should be possible to directly start activities written in Mono for Android from Java. It is still not clear to me how to reference the Mono for Android from Java and Googling yields no relevant hits. Really stumped now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:17:21+00:00Added an answer on June 10, 2026 at 4:17 pm

    If I’m understanding correctly what you’re trying to do, this isn’t really possible. As the error message you got implies, an Activity within a Mono for Android application relies on the Mono runtime in order to function properly. The callable wrapper isn’t useful on its own in this case, since it’s just a thin Java wrapper class that calls into the Mono runtime. You can actually see the generated callable wrappers yourself if you look in the obj/Debug/android/src folder after you build your project. For example:

    package androidapplication9;
    
    
    public class Activity1
        extends android.app.Activity
        implements
            mono.android.IGCUserPeer
    {
        static final String __md_methods;
        static {
            __md_methods = 
                "n_onCreate:(Landroid/os/Bundle;)V:GetOnCreate_Landroid_os_Bundle_Handler\n" +
                "";
            mono.android.Runtime.register ("AndroidApplication9.Activity1, AndroidApplication9, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", Activity1.class, __md_methods);
        }
    
    
        public Activity1 ()
        {
            super ();
            if (getClass () == Activity1.class)
                mono.android.TypeManager.Activate ("AndroidApplication9.Activity1, AndroidApplication9, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "", this, new java.lang.Object[] {  });
        }
    
    
        public void onCreate (android.os.Bundle p0)
        {
            n_onCreate (p0);
        }
    
        private native void n_onCreate (android.os.Bundle p0);
    
        java.util.ArrayList refList;
        public void monodroidAddReference (java.lang.Object obj)
        {
            if (refList == null)
                refList = new java.util.ArrayList ();
            refList.add (obj);
        }
    
        public void monodroidClearReferences ()
        {
            if (refList != null)
                refList.clear ();
        }
    }
    

    That said, due to the way Android works, you could have a Java application start an activity that is defined in a Mono for Android application in the same way you’d start an external Java activity. This relies on both applications being installed, of course, but would result in the Mono for Android application and Mono runtime actually starting up to run that activity.

    Edit

    Updating to answer the questions you posed in your comment. The ExportAttribute basically just gives you some more control in how the ACW gets generated, allowing you to specify that a particular method or field should be present in the ACW and what name it should have. This can be useful when you want to use things like an android:onClick attribute in a layout, for example, where by default the ACW wouldn’t contain the method you want to reference.

    You can’t get much use out of an ACW outside of the context of a Mono for Android application since the Mono runtime wouldn’t be present. Code written in C# is executed on top of the Mono runtime, and not translated into Java behind the scenes during compilation or anything like that. At runtime there are then two runtimes going side by side, Dalvik (Android’s runtime) and Mono, and the callable wrappers are there to allow the two to communicate back and forth. Because of that, even a Mono for Android class library would still depend on the Mono runtime, so you cannot use it independently of that runtime.

    This diagram shows what the architecture looks like, and how the runtimes relate to each other:

    Mono for Android architecture

    Hope this helps clear things up!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a WCF data service over a fairly simple EF 4.1 code
I have created a simple PHP login system, I am fairly new to PHP
I am fairly new to php and mysql but I have created a small
I have created an android application that calls (using kSOAP library) a SOAP based
This seems like a fairly simple problem to me but I have been having
I have fairly simple problem but I can not think of the simple solution.
I have a fairly simple web app that uses cookies to store some information
I have a fairly simple database that I inherited. For the purposes of this
I have a fairly simple PyQt application in which I'm placing instances of a
I have a fairly simple iPhone application that I want to have run on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.