Android Monodroid-加载自定义活动
我目前正在尝试使用Mono在Android下开发一个应用程序。 我想为我的应用程序添加插件支持,这样就可以为它带来额外的功能 我能够在运行时在程序中加载simple.dll,但是每当我尝试创建一个实现接口和自定义活动的dll时,就会抛出Java.Lang.NoClassDefFoundError类型的异常 dll代码中有一个类:Android Monodroid-加载自定义活动,android,android-activity,xamarin.android,Android,Android Activity,Xamarin.android,我目前正在尝试使用Mono在Android下开发一个应用程序。 我想为我的应用程序添加插件支持,这样就可以为它带来额外的功能 我能够在运行时在程序中加载simple.dll,但是每当我尝试创建一个实现接口和自定义活动的dll时,就会抛出Java.Lang.NoClassDefFoundError类型的异常 dll代码中有一个类: [Activity (Label = "Vestiaire")] public class Vestiaire : Activity, IModule {
[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);
}
}
负责异常的行:(来自程序核心)
我想知道的是:
-有可能实现我想要的目标吗?
如果是的话,将对该问题提供帮助:P
否则,最好的选择是什么?
全局点是能够在运行时从dll加载自定义菜单
谢谢。我认为您的问题的关键在于需要在Manifest.xml文件中注册活动 对于主应用程序中的活动,MonoDroid会为您执行此操作-但我认为这对您的插件不起作用 你可以尝试的是:
- 自己将活动放入清单中(MonoDroid似乎非常有能力合并这些文件)
- 如果这不起作用,那么你可以尝试使用一个片段来代替——并将片段加载到主应用程序中的自定义FragmentActivity中
LoadedPlugin.Add((IModule)(Activator.CreateInstance(Plugin)));