应用程式当机,但程式码中没有错误

时间:2019-03-28 17:54:35

标签: java android

在错误日志中以及该应用崩溃后,我得到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.+'

}

如果我将应用程序兼容性更新为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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

添加实现'com.android.support:design:28.0.0'后,此问题已解决。谢谢大家的评论。