EvilSakray
EvilSakray

Reputation: 40

Monodroid - Loading a custom activity

I'm currently trying to develop an application under Android using Mono. I'd like to add support for plugins to my application so additional features could be brought to it.

I was able to load simple .dll at runtime in my program, however whenever I try creating a dll implementing both my interface and a custom activity, an exception of type Java.Lang.NoClassDefFoundError is thrown.

There is the class inside the dll code:

[Activity (Label = "Vestiaire")]
public class Vestiaire : Activity, IModule
{   

    public string Name { get; set; }
    public string Version { get; set; }

    void OnClickVestiaireButton(object sender, System.EventArgs e)
    {
        ;
    }

    public void InitVestiaireModule()
    {
        Run();
    }

    public Type LaunchActivity ()
    {
        return typeof(Vestiaire);
    }

    public void Init()
    {
        Name = "Vestiaire Module";
        Version = "0.1";
    }

    public void Run()
    {

    }

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
    }
}

The line responsible for the exception: (from the program core)

LoadedPlugin.Add((IModule)(Activator.CreateInstance(Plugin)));

Things I'm actually wonderring are: - Is it possible to actually achieve what i'm trying to ? If yes, help would be apreciated on that problem :P

Otherwise what would be the best alternative ? Global point is to be able to load a custom menu at runtime loaded from a dll.

Thanks.

Upvotes: 0

Views: 132

Answers (1)

Stuart
Stuart

Reputation: 66882

i think the key to your problem is that the Activity needs to be registered in you Manifest.xml file.

For Activities in you main app, MonoDroid does this for you - but I don't think this will work for your plugin.

Things you could try are:

  • putting the Activity in the Manifest yourself (MonoDroid does seem very capable at merging these files)

  • if that doesn't work, then you could try using a Fragment instead - and loading the Fragment into a custom FragmentActivity in your main app.

Upvotes: 1

Related Questions