我在启动我的应用程序时遇到了问题,它说: System.NotSupportedException:无法将Java类型'md571f7fe98ab2dde9bbbc9832d751ab67e / MainActivity'的Java类型的JNI句柄0x7fe5716ca0(key_handle 0x5c7a272)激活为托管类型'MyFriends.MainActivity'。
plz帮助我解决此问题。 我使用的是JDK版本1.8.0.212
这是我在第一页中的XML编码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvFriends" />
这是我的活动
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity :Activity
{
FriendRepository db = new FriendRepository();
private ListView lvFriends;
protected override void OnCreate(Bundle Bundle)
{
base.OnCreate(Bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
lvFriends = FindViewById<ListView>(Resource.Id.lvFriends);
RestList();
lvFriends.ItemClick += LvFriends_ItemClick;
}
private void LvFriends_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
int friendId = (int)e.Id;
Android.Content.Intent editIntent = new Intent(this, typeof(DetailActivity));
editIntent.PutExtra("FriendID", friendId);
StartActivity(editIntent);
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.ListViewMenu, menu);
return base.OnCreateOptionsMenu(menu);
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.actionNew:
{
StartActivity(typeof(DetailActivity));
break;
}
case Resource.Id.actionRefresh:
{
RestList();
break;
}
}
return base.OnOptionsItemSelected(item);
}
protected override void OnResume()
{
RestList();
base.OnResume();
}
void RestList()
{
lvFriends.Adapter = new FriendAdapter(this, db.GetAllFriend());
}
}