После импорта внешних библиотек в мой проект каждый раз, когда я запускаю проект, я получаю ClassNotFoundException:
06-09 18:22:49.759 12976-13005/? E/AndroidRuntime: FATAL EXCEPTION: dataLoader
Process: prm.soundpaint, PID: 12976
org.neuroph.core.exceptions.NeurophException: Class not found while trying to read neural network from file!
at org.neuroph.core.NeuralNetwork.load(NeuralNetwork.java:638)
at prm.soundpaint.DrawingView$1.run(DrawingView.java:60)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.classic.Logger
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2263)
at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1641)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:657)
at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1782)
at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1113)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:454)
at org.neuroph.core.NeuralNetwork.readObject(NeuralNetwork.java:651)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1330)
at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1242)
at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
at org.neuroph.core.NeuralNetwork.load(NeuralNetwork.java:631)
at prm.soundpaint.DrawingView$1.run(DrawingView.java:60)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "ch.qos.logback.classic.Logger" on path: DexPathList[[zip file "/data/app/prm.soundpaint-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2263)
at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1641)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:657)
at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1782)
at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1113)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:454)
at org.neuroph.core.NeuralNetwork.readObject(NeuralNetwork.java:651)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1330)
at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1242)
at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
at org.neuroph.core.NeuralNetwork.load(NeuralNetwork.java:631)
at prm.soundpaint.DrawingView$1.run(DrawingView.java:60)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: ch.qos.logback.classic.Logger
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 24 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
JAR-файлы находятся внутри папки 'libs': libs
Iтакже добавлены зависимости в build.gradle:
android {
compileSdkVersion 27
defaultConfig {
applicationId "prm.soundpaint"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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 files('libs/neuroph-core-2.94.jar')
implementation files('libs/neuroph-imgrec-2.94.jar')
implementation files('libs/neuroph-ocr-2.94.jar')
}
Он вылетает в строке, где инициализируется объект:
private Runnable loadDataRunnable = new Runnable() {
public void run() {
InputStream irs = getResources().openRawResource(R.raw.m1);
nnet = NeuralNetwork.load(irs);
}
};
Я пытался решить эту проблему, отключив мгновенный запуск в Android Studio, нобез эффекта.Я также попытался:
- удалить папку сборки, очистить и пересобрать проект
- сделать недействительными кэши и перезапустить
- перезагрузить устройство
включитьmultiDex в build.gradle и в файле манифеста:
compile 'com.android.support:multidex:1.0.0' multiDexEnabled true android: name = "android.support.multidex.MultiDexApplication"
отключение preDexLibraries с помощью dexOptions {preDexLibraries false}
EDIT Снимок экрана рабочего пространства проекта
К сожалению, приложение по-прежнему вылетает при каждом запуске.У меня устройство с Android 5. Кто-нибудь знает, как решить эту проблему?