NoClassDefFoundError: Failed resolution of: Landroid/support/v4/media/MediaBrowserCompat$ConnectionCallback;

  android, androidx, plugins, unity3d

I’m relatively new to Android and I’m trying to write a plugin for unity3d that uses MediaBrowerService and MediaBrowserCompact.

When I run the plug-in on Unity I get a NoClassDefFoundError but I can figure out how to include the dependency.

This is my gradle:

plugins {
    id 'com.android.library'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    afterEvaluate {
        assembleDebug.finalizedBy(exportJar)
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.media:media:1.2.1'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

Source: Android Questions

LEAVE A COMMENT