gpt4 book ai didi

android - java.lang.NoClassDefFoundError:无法解决以下问题:Lcom/mapbox/android/telemetry/MapboxTelemetry;

转载 作者:行者123 更新时间:2023-12-03 04:07:29 32 4
gpt4 key购买 nike

我正在学习mapbox,并且已经在kotlin和following mapbox tutorial之后实现了mapbox
但是当我运行代码时,我在运行真实设备时遇到异常

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)
我想知道是什么导致异常
我尝试过的操作我添加了以下mapbox proguard-rules
在我的proguard-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(:app)下面
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'
}
我想知道我到底在哪里犯了错误,任何提示,建议,帮助都非常有用!

最佳答案

我认为当您将mapbox添加为本地依赖项时,某些依赖项未包含在项目中,因此请添加以下代码行;解决了我的问题,当然会产生新的错误,但要消除遥测错误:

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

关于android - java.lang.NoClassDefFoundError:无法解决以下问题:Lcom/mapbox/android/telemetry/MapboxTelemetry;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64104902/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com