Reputation: 55
I'm a having a bit of a problem trying to build an Android project in Eclipse. It seems to be a common problem but I've tried every possible solution provided by the other SO threads without getting anywhere. I am trying to use a simple class:
package qwe;
public class asd {
public asd() { }
}
Followed by typing this at the command prompt:
javac -d . -cp %classpath%;. asd.java
jar cvf asd.jar qwe
Android main activity code:
package com.example.zxc;
import android.os.Bundle;
import qwe.asd;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView t = new TextView(this);
try {
asd a = new asd();
}
catch( Throwable ex ) {
t.setText( ex.toString() );
setContentView( t );
}
}
}
I am importing the jar archive into an android project with eclipse by right clicking the libs project and adding the jar file, checking the jar in the project -> build path -> java tab, cleaning the project and then building. The compilation process does not throw any errors but i am getting a NoClassDefFoundError exception when running the app. This is just a test so that i can start working on a project with some real code but not even this simple attempt seems to give any results. What could I be missing ? Thanks.
Upvotes: 1
Views: 183
Reputation: 55
Compiled for version 1.6:
javac -d . -cp %classpath%;. -source 1.6 -target 1.6 asd.java
It works now. Thanks a lot guys.
Upvotes: 1
Reputation: 7439
First of all check your Build Path, if its fine and then also not working then right click on project-> Build path-> Configure Build path-> order and export-> Check your jar file there and make it up and clean the project and try it will work.
Upvotes: 0