2

Aloha to all.

There is an MPXJ.org project on Java to import MS project files of all versions, but the trouble is that for .mpp files higher than version 2000-2003 .mpp, for files higher than 2003 awt java lib is used awt.Color (getColor) that is not imported on Android and everything falls with

NoClassDefFoundError: Failed resolution of: Ljava/awt/Color;

here the basic code

MPPReader reader = new MPPReader();
String path2file = context.getFilesDir() + "/" +SAMPLE21_MPPX;
ProjectFile projectFile = reader.read(path2file); //<-- falling here

E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.example.bio.tj, PID: 13427

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Color;

at net.sf.mpxj.mpp.MPPUtility.getColor(MPPUtility.java:543) etc...

and this MPXJ also depends on the Apache POI, which is normally not importing to Android, too, do not connect, I used this Assembly: https://github.com/centic9/poi-on-android

There is the solution for awt.Color, but here I don't understand what to do.

BIOjack
  • 71
  • 1
  • 9

2 Answers2

2

It looks like the version of POI for Android that you provided a link to already solves this issue. Here is the definition of java.awt.Color provided by poi-on-android:

https://github.com/centic9/poi-on-android/blob/master/poishadow/src/main/java/org/apache/poi/java/awt/Color.java

Hopefully you'll either be able to use this source directly in your project, or pick up the class from the poi-on-android JAR itself.

Jon Iles
  • 2,519
  • 1
  • 20
  • 30
0

Here is step by step solution.

  • open poi-on-android project in android studio
  • add to build.gradle (Module: poishadow)

// after this 2 lines

compile 'org.apache.poi:poi-ooxml:3.17'

compile 'com.fasterxml:aalto-xml:1.0.0'

// add this line with mpxj gradle

compile group: 'net.sf.mpxj', name: 'mpxj', version: '7.2.1'

  • compile project, get file \poi-on-android-master\poishadow\build\libs\ poishadow-all.jar

it is all in one apache poi and mpxj, after that I took this file and imported in my project, seems working fine for the first run (tested on ms project 2010/2016 file), and onCreate in my project I added

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        System.setProperty("org.apache.poi.javax.xml.stream.XMLInputFactory", "com.fasterxml.aalto.stax.InputFactoryImpl");
        System.setProperty("org.apache.poi.javax.xml.stream.XMLOutputFactory", "com.fasterxml.aalto.stax.OutputFactoryImpl");
        System.setProperty("org.apache.poi.javax.xml.stream.XMLEventFactory", "com.fasterxml.aalto.stax.EventFactoryImpl");
BIOjack
  • 71
  • 1
  • 9