I ran into this error while integrating ADM into my flutter project, add things mentioned in the doc(namespace in manifest, compileOnly the jar in build.gradle), and NoClassDefFoundError still happened in my AVD, Android 13 Tiramisu, please help

Exception

java.lang.NoClassDefFoundError: Failed resolution of: com/amazon/device/messaging/ADM;

at com.app.waylung.waylungs.MainActivity.register(MainActivity.java:87)

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.amazon.device.messaging.ADM" on path: DexPathList\[\[zip file "/data/app/\~\~69BXTW88bs0FaMwICnRL3g==/com.app.waylung.waylungs-ktV3gociNJ_rLMjQCA7WQQ==/base.apk"\],nativeLibraryDirectories=\[/data/app/\~\~69BXTW88bs0FaMwICnRL3g==/com.app.waylung.waylungs-ktV3gociNJ_rLMjQCA7WQQ==/lib/x86_64, /data/app/\~\~69BXTW88bs0FaMwICnRL3g==/com.app.waylung.waylungs-ktV3gociNJ_rLMjQCA7WQQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64\]\]

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:amazon="http://schemas.amazon.com/apk/res/android"
    package="com.app.waylung.waylungs" >
    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />
    <permission
        android:name="com.app.waylung.waylungs.permission.RECEIVE_ADM_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.app.waylung.waylungs.permission.RECEIVE_ADM_MESSAGE" />
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <application
        android:label="waylungs"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <amazon:enable-feature
            android:name="com.amazon.device.messaging"
            android:required="true"/>
        <service
            android:name="waylungs"
            android:permission="android.permission.BIND_JOB_SERVICE"
            android:exported="false" />
        <receiver
            android:exported="true"
            android:name="waylungs"
            android:permission="com.amazon.device.messaging.permission.SEND" >
            <intent-filter>
                <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
                <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
                <category android:name="com.amazon.device.messaging" />
            </intent-filter>
        </receiver>
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

build.gradle

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    compileOnly files('libs/amazon-device-messaging-1.2.0.jar')
}

tried to

upgrade / downgrade Android API level from 33 to 28, flutter verion from 3.3 to 2.0.6

included or remove amazon-device-messaging-1.2.0.jar in android/app/libs

from compileOnly files('libs/amazon-device-messaging-1.2.0.jar') to implementation files('libs/amazon-device-messaging-1.2.0.jar') this hit stub exception of coz

0

There are 0 best solutions below