0

I am using a .NET Standard Xamarin solution and when creating my own classes in the android part, they do not get included with the .apk

I am getting the following exception:

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]]

I have used https://github.com/google/android-classyshark to check:

Total method count: 27569

The md51d6... folder is not in the APK, but when I check obj/Debug/android/bin/classes the folder is in there

Using API Version:25

Built action: Compile

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();

    }
}

Services/TestService.cs

namespace DriverApp.Droid.Services
{
    class TestService : Service
    {
        public override IBinder OnBind(Intent intent)
        {
            throw new NotImplementedException();
        }
    }
}
Mazzy
  • 1,901
  • 2
  • 16
  • 36
  • The class isn't complied to your .apk, please clean and rebuild or you need to restart your Visual studio. – Robbit Dec 12 '17 at 06:00
  • Funny to mark this as a duplicate while the question states that it does not exceed the 64k limit. In the end, it had nothing to do with multi-dex since it was already enabled – Mazzy Dec 31 '17 at 10:57

1 Answers1

3

The solution was to uninstall the app manually from the test device.

Cleaning and rebuilding alone did not work, I had to first uninstall the app from the device....

Mazzy
  • 1,901
  • 2
  • 16
  • 36