J
J
jack72772018-02-22 18:21:03
Android
jack7277, 2018-02-22 18:21:03

Reading MS Project MPP/MPX under Android 5+?

Beaver everyone.
There is an MPXJ project in Java for importing all project files of all versions, but the trouble is that for .mpp files older than the xs version, it is called 2000-2003 .mpp, for older files awt.Color is used, which is not in the android environment and that's it crashes with NoClassDefFoundError: Failed resolution of: Ljava/awt/Color;

MPPReader reader = new MPPReader();
String path2file = context.getFilesDir() + "/" +SAMPLE21_MPPX;
ProjectFile projectFile = reader.read(path2file); <-- тута мы падаем

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.
moreover, this MPXJ also depends on Apache POI , which you can’t connect to android by default, I used this assembly: https://github.com/ centic9 / poi-on-android
there is also a solution for awt / Color, but here I don’t understand what to do already, you need to enable shadowJar and connect the shadow jar, which will replace the called one and xs what to do in the end, I made two jar files, I connected them to myself, which is further incomprehensible.
In short, Ben, this is Danila, ai nid help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jack7277, 2018-02-23
@jack7277

The solution turned out to be simple
- open the project in the studio https://github.com/centic9/poi-on-android
- add build.gradle (Module: poishadow)
compile 'org.apache.poi:poi-ooxml:3.17' to the lines
compile 'com.fasterxml:aalto-xml:1.0.0'
string including MPXJ
// https://mvnrepository.com/artifact/net.sf.mpxj/mpxj
compile group: 'net.sf.mpxj', name: ' mpxj', version: '7.2.1'
- then when compiling the project, the \poi-on-android-master\poishadow\build\libs\poishadow-all.jar file will be created
and at some stage everything will hang, but the file can be take and connect to your project, no longer shaman with shadows without doing anything, but also insert this in your project in onCreate:

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");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question