java.lang.NoClassDefFoundError: असफल संकल्प: Lcom / mapbox / android / telemetry / MapboxTelemetry;

Sep 29 2020

मैं मैपबॉक्स सीख रहा हूं और मैंने मैपबॉक्स ट्यूटोरियल के बाद कोटलिन के साथ मैपबॉक्स लागू किया है

लेकिन जब मैं कोड चलाता हूं तो मुझे असली डिवाइस चलाने के बाद अपवाद मिल रहा है

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/android/telemetry/MapboxTelemetry;
     at com.mapbox.mapboxsdk.module.telemetry.TelemetryImpl.<init>(TelemetryImpl.java:30)
     at com.mapbox.mapboxsdk.ModuleProviderImpl.obtainTelemetry(ModuleProviderImpl.java:22)
     at com.mapbox.mapboxsdk.Mapbox.initializeTelemetry(Mapbox.java:167)
     at com.mapbox.mapboxsdk.Mapbox.getInstance(Mapbox.java:64)
     at com.example.myapplication.MainActivity.onCreate(MainActivity.kt:18)
     at android.app.Activity.performCreate(Activity.java:7224)
     at android.app.Activity.performCreate(Activity.java:7213)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2956)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3113)
     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1858) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6820) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mapbox.android.telemetry.MapboxTelemetry" on path: DexPathList[[zip file "/data/app/com.example.myapplication-85zEOZQGHEn-PrcXcL50yg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-85zEOZQGHEn-PrcXcL50yg==/lib/arm, /system/lib]]
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

मैं जानना चाहता हूं कि अपवाद क्या है

मैंने जो भी कोशिश की है, मैंने निम्नलिखित मैपबॉक्स गार्ड-नियमों को जोड़ा है

मेरे प्रागड्स-rules.pro के नीचे

# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-dontwarn com.mapbox.services.android.location.LostLocationEngine
-dontwarn com.mapbox.services.android.location.MockLocationEngine


# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

नीचे build.gradle (: ऐप)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation project(':mapbox-android-sdk-9.5.0')

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

मैं जानना चाहता हूं कि वास्तव में मैंने कहां गलती की है, कोई संकेत, सुझाव, बहुत मदद की है!

जवाब

mortezahosseini Nov 07 2020 at 16:35

मुझे लगता है कि जब आप स्थानीय निर्भरता के रूप में मैपबॉक्स को जोड़ते हैं, तो परियोजना में कुछ निर्भरताएं शामिल नहीं होती हैं, इसलिए इस कोड को जोड़ें; मेरी समस्या हल हो गई है, निश्चित रूप से नई त्रुटि पैदा करता है, लेकिन टेलीमेट्री त्रुटि को हटा दें:

implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.2.0'