Ich möchte für die Berechnung der Standardabweichung der Apache Commons Math-Bibliothek verwenden, anstatt meine eigene Methode zu schreiben, aber ich habe nicht in der Lage gewesen, diesen Fehler zu beseitigen:Android Studio Commons Math „NoClassDefFoundError“
FATAL EXCEPTION: main
Process: io.github.hactarce.qtimer, PID: 25294
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/discovery/tools/DiscoverClass;
at org.apache.commons.math.stat.DescriptiveStatistics.newInstance(DescriptiveStatistics.java:91)
at ...
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.discovery.tools.DiscoverClass" on path: DexPathList[[dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-support-annotations-24.0.0_9d3ba58e638ed02faa84bf39a48fe2d24bde6b2a-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-me.zhanghai.android.materialprogressbar-library-1.1.6_3f4dfaff6ac84c0f0b41e456c4c7ea77b367a4b0-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-internal_impl-24.0.0_92a109cb571bd624e4bea6328895341c772d7c6c-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-commons-math-20040218.045431_cdd6a0543f856d0d318fbe7a891815a73a580ce9-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-com.android.support-support-vector-drawable-24.0.0_2a3a8f3ca104420ae4ace8cc58b02d413c7612ea-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0_bffc8401f241a00ed2f701ca43e6dffa2f80398d-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-com.android.support-recyclerview-v7-24.0.0_2c37df8ad6003e99ec2537a49be829f52468f887-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-com.android.support-appcompat-v7-24.0.0_73746d492da138f16fa685b4e64eeb56d351948f-classes.dex", dex file "/data/data/io.github.hactarce.qtimer/files/instant-run/dex/slice-com.android.support-animated-v
Mein Gradle Datei:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Apis:Google Apis:23'
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "io.github.hactarce.qtimer"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.afollestad.material-dialogs:core:0.8.6.0'
compile 'com.afollestad.material-dialogs:commons:0.8.6.0'
compile 'commons-math:commons-math:20040218.045431'
}
ich habe viele andere Antworten zu ähnlichen Fehlern gesehen, aber keiner von ihnen zu helfen scheint. Danke im Voraus. :)
Wow, das ist eine ** alte ** Version. 2004! Nun, es sieht so aus, als ob es 'commons-discovery' braucht, also müssen Sie auch diese Abhängigkeit hinzufügen. Um zu passen, was Sie haben, benötigen Sie wahrscheinlich Commons-Discovery: commons-discovery: 20040218.194635. Da es das gleiche (sehr alte) * Datum hat, passen sie wahrscheinlich zusammen. --- Vorschlag: Upgrade auf etwas Aktuelleres. Ich meine, Android gab es damals noch nicht! – Andreas
Huch ... vielleicht werde ich sie selbst umerziehen. : s – Hactar
Warum reimplementieren Sie sich selbst? Verwenden Sie einfach eine [neuere Version] (http://commons.apache.org/proper/common-math/index.html), z. 'org.apache.commons: commons-math3: jar: 3.6.1'. Version 3.6.1 wurde am 21.03.2016 veröffentlicht. – Andreas