Java.Lang.Classnotfoundexception: Didn't Find Class on Path: Dexpathlist

Didn't find class on path: DexPathList?

I did not find any perfect solution for my problem.But when I upload my apk on google play and download from there,app is working fine.This is the most weird solution I have ever found.

Didn't find class on path: dexpathlist

Same problem here.
What worked for me was adding android-support-v4.jar as a lib and making sure it was checked on Project properties -> Build Path -> Order & export.
It was mentioned here

Flutter crashes on startup: Didn't find class .MainActivity on path DexPathList

My findings suggest this is not an issue with Flutter itself, but occurs after particular Flutter package installations.
After upgrading Gradle and the AndroidX libraries, the crash disappeared and then re-appeared after another Flutter package addition. Then I cleaned (build->clean in the IDE) the android project again and it was fixed once again. So it may be due to some Gradle confusions in my environment and probably it just doesn't compile some classes the right way from time to time.

Unknown error: Didn't find class on path: DexPathList

You have to enable multidex for apps with over 64K methods.

Modify your build.gradle:

android {
compileSdkVersion 22
buildToolsVersion "23.0.0"

defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22

// Enabling multidex support.
multiDexEnabled true
}
}

dependencies {
implementation 'com.android.support:multidex:1.0.3'
}

If you are running unit tests, you will want to include this in your Application class:

public class YouApplication extends Application {

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

}

Or just make your application class extend MultiDexApplication

public class Application extends MultiDexApplication {

}

Note:
Android 5.0 (API level 21) and higher uses ART which natively supports multidexing. Therefore, if your minSdkVersion is 21 or higher, the multidex support library is not needed.

java.lang.ClassNotFoundException: on path: DexPathList[[directory .],nativeLibraryDirectories=[/system/lib64, /system/lib64]]

FindClass will not be able to find any of your app-specific classes if invoked on a purely native thread, due to the wrong classloader being used. See this section in the Android developer documentation for more information.

There are various ways in which you could solve this, but the easiest is probably to resolve all classes in JNI_OnLoad, create global references to them, and save those global references somewhere where the rest of your code can access them.

How to solve Didn't find class ... on path: DexPathList in my native callback to Java

I solved the problem mostly myself (Reading through @Michael's suggestion in the comment and a few other places mentioned there definitely helped!):

First, I separated the "setup" part from the actual callback function (This was the plan all along, but not doing it first stood in the way of seeing the problem).

Second, in my native_lib.cpp I created a global reference to my jobject (the "instance" object in playFromJNI from the example in the question) before passing it into AudioCallback's constructor like this:

    myJNIClass = env->NewGlobalRef(instance);
callback = std::make_unique<AudioCallback>(*g_jvm, myJNIClass);

Third, in the actual callback method playbackProgress I only handle the ÀttachToCurrentThread` if necessary, and use the class members, that I have initialized beforehand with the correct data.

This is what my AudioCallback implementation looks like now:

#include <jni.h>>
#include <utils/logging.h>
#include "AudioCallback.h"


jclass target;
jmethodID id;

AudioCallback::AudioCallback(JavaVM &jvm, jobject object) : g_jvm(jvm), g_object(object) {
JNIEnv *g_env;
int getEnvStat = g_jvm.GetEnv((void **) &g_env, JNI_VERSION_1_6);
LOGD("Env Stat: %d", getEnvStat);

if (g_env != NULL) {
target = g_env->GetObjectClass(g_object);
id = g_env->GetMethodID(target, "integerCallback", "(I)V");
}
}

void AudioCallback::playBackProgress(int progressPercentage) {
JNIEnv *g_env;
int getEnvStat = g_jvm.GetEnv((void **) &g_env, JNI_VERSION_1_6);

if (getEnvStat == JNI_EDETACHED) {
LOGD("GetEnv: not attached - attaching");
if (g_jvm.AttachCurrentThread(&g_env, NULL) != 0) {
LOGD("GetEnv: Failed to attach");
}
} else if (getEnvStat == JNI_OK) {
LOGD("GetEnv: JNI_OK");
} else if (getEnvStat == JNI_EVERSION) {
LOGD("GetEnv: version not supported");
}
g_env->CallVoidMethod(g_object, id, (jint) progressPercentage);
}

This now works for me as desired, but since I'm not a C++/JNI expert, there might still be problems in my code. Feel free to point them out!

ClassNotFoundException: Didn't find class on path: DexPathList

Update

After a long time, It turned out that it must have anything to do with proguard. I can´t really say what exactly the error causes, but I tried a little bit and that´s what I noticed (that´s in my case with Eclipse IDE):

  • I have to close every tab from the project I want to sign
  • I have to clean the project and after cleaning, do nothing but export the apk
  • making a small change in manifest, save it and undo the change (and save)
  • if there is any class in manifest named with "YourClass" or ".YourClass", change it to "com.yourpackage.yourClass"

That are the four points I have done and then it worked. This looks suspicious, but I think there is a problem with obfuscating. Because without doing these points, I can simply compile my apk and install it from eclipse. For me, there is no obvious reason for this behavior.
Also the package name does work without a change if I only install it from eclipse.
I hope these points can help somebody.



Related Topics



Leave a reply



Submit