Bashima Bashima - 4 years ago 288
Android Question

java.lang.NoClassDefFoundError: for using JavaML libsvm in Android

I am using java ml for lib svm. But I am getting java.lang.NoClassDefFoundError: libsvm.LibSVM$1 error while initializing a LibSvm object. I have added these lines in my gradle:



dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile project(':javaml-0.1.7')
}





This is the Activity code. The error occurs when I initialize libSVM.



import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import net.sf.javaml.core.Dataset;

import libsvm.LibSVM;


public class MainActivity extends AppCompatActivity {

public LibSVM libSVM;
Dataset dataset;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
libSVM = new LibSVM();

}
}




Answer Source

I only added the javaml-0.1.7.jar before. But there is also a libsvm.jar in the lib folder of javaml-0.1.7. Importing that library solved the problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download