应用程序崩溃但代码中没有错误

问题描述 投票:-1回答:2

我在错误日志中得到java.lang.NoSuchMethodError,之后该应用程序崩溃了。我的java代码中没有任何错误。我不确定哪个库导致了这个问题。非常感谢您的帮助。

我已经更新了几个库到28和27但仍然得到相同的错误。

错误

java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/support/v4/content/res/ConfigurationHelper; or its super classes (declaration of 'android.support.v4.content.res.ConfigurationHelper' appears in /data/app/com

的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'

implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.facebook.android:account-kit-sdk:4.+'

}

如果我将appcompat更新为28,那么我将收到以下错误。

  implementation 'com.android.support:appcompat-v7:28.0.0'


 * What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.design.widget.CoordinatorLayout$1
java android
2个回答
2
投票

没有完整的堆栈跟踪,就无法确定错误的来源。在您的构建文件中唯一看起来可疑的是您没有常见的Android支持版本。您使用27.0.028.0.0版本的库。


1
投票

添加实现'com.android.support:design:28.0.0'后,此问题得到解决。感谢大家的意见。

© www.soinside.com 2019 - 2024. All rights reserved.