Xamarin ClassNotFoundException DexPathList

时间:2017-12-11 10:45:22

标签: xamarin xamarin.android

我正在使用.NET标准Xamarin解决方案,当在android部分创建我自己的类时,它们不会包含在.apk中

我收到以下异常:

Java.Lang.ClassNotFoundException: Didn't find class "md51d6fa235ea481c9f9b4025a1ec847f9d.TestService" on path: DexPathList[[zip file "/data/app/com.gete.DriverApp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.gete.DriverApp-1/lib/arm64, /data/app/com.gete.DriverApp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]

我使用https://github.com/google/android-classyshark来检查:

总方法计数:27569

md51d6...文件夹不在APK中,但当我检查obj/Debug/android/bin/classes文件夹在那里时

使用API​​版本:25

内置动作:编译

MainActivity.cs

[IntentFilter(new[] { Intent.ActionView },
    Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
    DataScheme = "test",
    DataHost = "open.rides",
    DataPathPrefix = "",
    AutoVerify = true)]
[Activity(Label = "DriverApp.Android", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);
        AndroidAppLinks.Init(this);

        LoadApplication(new App());

        var loci = new TestService();

    }
}

服务/ TestService.cs

namespace DriverApp.Droid.Services
{
    class TestService : Service
    {
        public override IBinder OnBind(Intent intent)
        {
            throw new NotImplementedException();
        }
    }
}

1 个答案:

答案 0 :(得分:3)

解决方案是从测试设备手动卸载应用程序。

单独清洁和重建不起作用,我必须先从设备中卸载应用程序....