So I need to use the jexcelApi for my Android project. After including it, I get no compiler error, but a runtime Exception NoClassDefFoundError on my device for every single class I use from that jar. Decompiling it shows that the needed classes are inside the jar.
I did following steps:
- Downloaded the jar
- Copied it to {Root_Folder}/libs
compile fileTree(include: ['*.jar'], dir: 'libs')
is in my gradle build script- Called clean project
- Built the project
Full logcat entry:
05-11 23:28:05.234 26289-26289/? E/Assignment: Spreadsheet Error
java.lang.NoClassDefFoundError: jxl.write.WritableFont
at com.example.bene.assignment.spreadsheet.SpreadsheetController.<init>(SpreadsheetController.java:43)
at com.example.bene.assignment.spreadsheet.SpreadsheetController.create(SpreadsheetController.java:34)
at com.example.bene.assignment.MainActivity.onCreate(MainActivity.java:62)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)bs')
regards following code:
// create Formats
WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10);
// Define the cell format
mTimes = new WritableCellFormat(times10pt);
// Lets automatically wrap the cells
mTimes.setWrap(true);
// create create a bold font with unterlines
WritableFont times10ptBoldUnderline = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.SINGLE);
mTimesBoldUnderline = new WritableCellFormat(times10ptBoldUnderline);
// Lets automatically wrap the cells
mTimesBoldUnderline.setWrap(true);
I really don't know, how to proceed, please help me! Thank you in advance.
UPDATE
So I just found out, that some packages have got transitive dependencies which have to be included to compile them. So I found following links:
- Maven repository
- Sourceforge (cant post it because of stackoverflow restrictrions)
First saying that I'd need compile 'log4j:log4j:1.2.14'
, second saying that I'd need
compile 'org.slf4j:slf4j-api:1.7.2'
compile 'org.slf4j:slf4j-log4j12:1.7.2'
Following the Maven-link, I get the same result via
compile('net.sourceforge.jexcelapi:jxl:2.6.12') {
transitive= true
}
which makes my dependency tree on that task look like following: Dependency Tree
Still getting the same Exception ...