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 ''
compile project(':javaml-0.1.7')

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

import android.os.Bundle;

import net.sf.javaml.core.Dataset;

import libsvm.LibSVM;

public class MainActivity extends AppCompatActivity {

public LibSVM libSVM;
Dataset dataset;
protected void onCreate(Bundle savedInstanceState) {
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