Page 1 of 1

Images?

PostPosted: Fri Sep 05, 2014 8:35 am
by drew.coleman
Does anyone have any guidance for adding images on Android? I cannot get it to work.

If I include the awt jar included in the Android library, I get the too many methods error when it dexes the libraries for build.

Re: Images?

PostPosted: Sat Sep 06, 2014 7:14 am
by drew.coleman
I would just like to say that I got this working.

First, I had to follow the normal instructions for getting it to work on Android as found here:
http://www.docx4java.org/blog/2012/05/j ... n-android/
and here
https://github.com/plutext/AndroidDocxToHtml

Take the jar files from the AndroidDocxToHtml libs folder and use those in your own project.

To get images working, I used the jar files from this SO answer by kirik88
http://stackoverflow.com/questions/2332 ... e/23647090

But after all of this, I was running into the method limit with dex files. So I enabled proguard on debug - add
debug {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
to your build types entry (under the android entry) in build.gradle for your module.

Next, I had to go into proguard and set things up there. Here is the contents of my proguard file:
-libraryjars "libs/activation.jar"
-libraryjars "libs/additionnal.jar"
-libraryjars "libs/ae-awt.jar"
-libraryjars "libs/ae-docx4j-2.8.0-SNAPSHOT.jar"
-libraryjars "libs/ae-jaxb-2.2.5.jar"
-libraryjars "libs/ae-xmlgraphics-commons.jar"
-libraryjars "libs/commons-codec-1.3.jar"
-libraryjars "libs/commons-io-1.3.1.jar"
-libraryjars "libs/commons-lang-2.4.jar"
-libraryjars "libs/commons-logging-1.1.1.jar"
-libraryjars "libs/gson-2.2.4.jar"
-libraryjars "libs/istack-commons-runtime.jar"
-libraryjars "libs/JAXBNamespacePrefixMapper-2.2.4.jar"
-libraryjars "libs/jaxp-datatype.jar"
-libraryjars "libs/log4j-1.2.15.jar"
-libraryjars "libs/txw2-20110809.jar"

-ignorewarnings
-dontobfuscate

-keep class ae.com.sun.** { public protected private *; }
-keep class ae.javax.** { public protected private *; }
-keep class org.apache.** { public protected private *; }
-keep class org.docx4j.** { public protected private *; }
-keep class org.opendope.** { public protected private *; }
-keep class com.sun.** { public protected private *; }

After that, I was able to build and run normally and use the guides for adding images/tables/etc to a new word document.

Cheers. If anyone has any questions about this, please PM me or email drew.coleman@covan.com

Re: Images?

PostPosted: Sat Sep 06, 2014 9:19 am
by jason
Nice work Drew :-)

Does Proguard tell you how many classes/methods were left after it has done its thing?

Re: Images?

PostPosted: Mon Sep 08, 2014 2:36 am
by drew.coleman
Not that I can tell. I do remember seeing some scripts that would tell you that, but I never tested them.