Reputation: 2760
Has anyone imported this sliding menu project https://github.com/jfeinstein10/SlidingMenu in their Monodroid application?
I've imported the jar file (com.slidingmenu.lib.slidingmenuactivity.jar) in a new JavaLibraryProject.
I've created a new activity which extends from from SlidingActivity.
My project builds without any errors, but at runtime I get this exception
Java.Lang.NoClassDefFoundError: com.slidingmenu.lib.R$layout
on
base.OnCreate(bundle)
public class MainActivity : SlidingActivity
{
public override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle); //The EXCEPTION is thrown here
SetContentView(Resource.Layout.activity_main);
}
public override void SetBehindContentView(int p0)
{
base.SetBehindContentView(p0);
}
}
Any ideas anyone? Thanks :)
EDIT
Ok. I've done a little modification:
I've added the "assets", "bin" and "res" folders to a ".zip" file which I've added in my AndroidJavaLibrary project.
It compiles fine, but now I get another error on the same line:
Android.Views.InflateException: Binary XML file line #2: Error inflating class com.slidingmenu.lib.SlidingMenu
Upvotes: 5
Views: 3115
Reputation: 2760
I finally got it working
public class Activity1 : SlidingActivity
{
int count = 1;
public override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
SetBehindContentView(Resource.Layout.menu);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
}
And I updated Monodroid to the latest version 4.4.54
Hope this helps someone :)
Upvotes: 0
Reputation: 8370
You need to include the Jar in both your Java Binding Library and your Mono for Android application. Just add a folder called libs to your Mono for Android project and copy the Jar file into that. You need to then set the build action to AndroidJavaLibrary.
So your solution should look like this:
Upvotes: 4