Reading MS Excel 2010 files in android using Apache POI - android

I am using Apache POI in my android application to read xlsx file stored in SDCARD.
I am using following jar libs from Apache POI
poi-ooxml-schemas-3.9-20121203.jar
poi-ooxml-3.9-20121203.jar
But when I try to Run Android App I am getting below mentioned stacktrace.
trouble writing output: Too many methods: 66024; max is 65536. By package:
13 java.lang
1 java.lang.reflect
5 java.util
1 javax.xml.namespace
66 org.apache.xmlbeans
19 org.apache.xmlbeans.impl.values
1 org.apache.xmlbeans.impl.xb.xmlschema
2500 org.openxmlformats.schemas.drawingml.x2006.chart
1430 org.openxmlformats.schemas.drawingml.x2006.chart.impl
8767 org.openxmlformats.schemas.drawingml.x2006.main
5258 org.openxmlformats.schemas.drawingml.x2006.main.impl
86 org.openxmlformats.schemas.drawingml.x2006.picture
33 org.openxmlformats.schemas.drawingml.x2006.picture.impl
745 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing
417 org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl
230 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing
164 org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl
298 org.openxmlformats.schemas.officeDocument.x2006.customProperties
256 org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl
617 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes
596 org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl
285 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties
196 org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl
23 org.openxmlformats.schemas.officeDocument.x2006.math
24 org.openxmlformats.schemas.officeDocument.x2006.relationships
2 org.openxmlformats.schemas.officeDocument.x2006.relationships.impl
2076 org.openxmlformats.schemas.presentationml.x2006.main
1224 org.openxmlformats.schemas.presentationml.x2006.main.impl
1 org.openxmlformats.schemas.schemaLibrary.x2006.main
7271 org.openxmlformats.schemas.spreadsheetml.x2006.main
4556 org.openxmlformats.schemas.spreadsheetml.x2006.main.impl
11448 org.openxmlformats.schemas.wordprocessingml.x2006.main
9217 org.openxmlformats.schemas.wordprocessingml.x2006.main.impl
4 schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707
1170 schemasMicrosoftComOfficeExcel
1223 schemasMicrosoftComOfficeExcel.impl
285 schemasMicrosoftComOfficeOffice
124 schemasMicrosoftComOfficeOffice.impl
2 schemasMicrosoftComOfficePowerpoint
3 schemasMicrosoftComOfficeWord
2858 schemasMicrosoftComVml
2529 schemasMicrosoftComVml.impl
[2013-11-25 21:20:32 - CRD] Conversion to Dalvik format failed with error 2
Can anyone tell where am I missing?

If you use too much code for any android app, the compilation will throw this error. The similar problem is stated and resolved here. You should split the app in parts as a plugin, in the form of a separate APK available for download. That APK would expose some component that the main app would use. There are various app on google play of such kind.

Please note that there are a number of problems when using Apache POI on Android. The one you are hitting can be solved by the so called "multiDex" feature in newer versions of Android.
There are currently two projects which try to solve most of the problems for you:
https://github.com/andruhon/android5xlsx
https://github.com/centic9/poi-on-android/ (mainted by me)
The first one is currently based on POI 3.12, whereas the second can be re-compiled with newer versions of POI more easily.

Related

Unity3D build error : Failed to compile resources

I use UltimateMobile plugin and uniwebview plugin ,maybe they are conflict.
when I build ,Unity3d console say :
Failed to compile resources with the following parameters:
-bootclasspath
"C:/Program Files/Java/android-sdk-windows\platforms\android-27\android.jar" -d
"C:\Game\3drq\superblocks\Temp\StagingArea\bin\classes"
-source 1.6 -target 1.6 -encoding UTF-8
"android\support\v4\Manifest.java"
"android\support\v4\R.java"
"com\cheerflame\superblocks\Manifest.java"
"com\cheerflame\superblocks\R.java"
"com\google\android\gms\Manifest.java"
"com\google\android\gms\R.java"
"com\google\android\gms\ads\Manifest.java"
"com\google\android\gms\ads\R.java"
"com\google\android\gms\ads\impl\Manifest.java"
"com\google\android\gms\ads\impl\R.java"
"com\google\android\gms\analytics\Manifest.java"
"com\google\android\gms\analytics\R.java"
"com\google\android\gms\appinvite\Manifest.java"
"com\google\android\gms\appinvite\R.java"
"com\google\android\gms\auth\Manifest.java"
"com\google\android\gms\auth\R.java"
"com\google\android\gms\auth\api\Manifest.java"
"com\google\android\gms\auth\api\R.java"
"com\google\android\gms\base\Manifest.java"
"com\google\android\gms\base\R.java"
"com\google\android\gms\drive\Manifest.java"
"com\google\android\gms\drive\R.java"
"com\google\android\gms\games\Manifest.java"
"com\google\android\gms\games\R.java"
"com\google\android\gms\gcm\Manifest.java"
"com\google\android\gms\gcm\R.java"
"com\google\android\gms\iid\Manifest.java"
"com\google\android\gms\iid\R.java"
"com\google\android\gms\plus\Manifest.java"
"com\google\android\gms\plus\R.java"
"com\stansassets\androidnative\Manifest.java"
"com\stansassets\androidnative\R.java"
"com\stansassets\billing\Manifest.java"
"com\stansassets\billing\R.java"
"com\stansassets\googleplay\Manifest.java"
"com\stansassets\googleplay\R.java"
"com\stansassets\mnp\Manifest.java"
"com\stansassets\mnp\R.java"
"com\stansassets\social\Manifest.java"
"com\stansassets\social\R.java"
����: C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/Object.class):
���汾 52 �� 51 ��, �˱�����֧�����µ����汾�����������˱�������
����: C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/String.class):
���汾 52 �� 51 ��, �˱�����֧�����µ����汾��
���������˱�������
����:
C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/AutoCloseable.class):
���汾 52 �� 51 ��, �˱�����֧�����µ����汾��
���������˱�������
3 ������
why there are so many messy code?
I build the project in another computer,it's fine and can be built to a apk file.
I don't understand ,please help me. thanks !
You should downgrade to JDK 8. According to this SO answer which has a similar error message to your question:
As of Unity 2017, Unity is incompatible with JDK 9. You need to
continue to use JDK 1.8 for the time being.
(Note: there is also an active issue on the Unity Issue Tracker for JDK 9 that seems to be related. It's not the exact same error message, but others are commenting there with your error message as well.)
(EDIT: The question's error message shows "android-27", so this may not be the actual solution. I'm leaving this here for now as a solution attempt, and because one of the most common reasons for this error message, in general, is the JDK version.)
(Also, to give one possible explanation for "why there are so many messy code?": the little question mark with the black box has to do with strings and character encodings. It likely has something to do with the asker's computer language being set to another language like Chinese. I'm not sure about the exact cause in this case, but see The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) for more background information about the black box question mark characters:
And in fact now that you’re thinking of things in terms of platonic
ideal letters which are represented by Unicode code points, those
unicode code points can be encoded in any old-school encoding scheme,
too! For example, you could encode the Unicode string for Hello
(U+0048 U+0065 U+006C U+006C U+006F) in ASCII, or the old OEM Greek
Encoding, or the Hebrew ANSI Encoding, or any of several hundred
encodings that have been invented so far, with one catch: some of the
letters might not show up! If there’s no equivalent for the Unicode
code point you’re trying to represent in the encoding you’re trying to
represent it in, you usually get a little question mark: ? or, if
you’re really good, a box. Which did you get? -> �

Error opening android support appcompat in eclipse from dandar3

dandar3 Google Play Services for eclipse always worked well. All project has a good synchronization.
But last time I caught bug of synchronization in android support appcompat project. Here is it:
All libraries in android support appcompat is correct. My system is Linux Mint 64. My default java is java-8-oracle(I tryed java-8-openjdk-amd64 no effect).
Mayby somebody faced that error? Please do not offer Android Studio. Thank you.
More details on the ticket on GitHub (link) but just to summarise it appears to be due to the fact that aidl tool only supports interfaces, it logs the message as an error and by design Google ADT plugin shows external errors as compiler errors.
The issue affects the Android Support Libraries 26.0.0 for Eclipse listed below, from which I will remove the offending .aidl files and release them again.
android-support-compat
android-support-media-compat
android-support-v4
https://android.googlesource.com/platform/system/tools/aidl/+/master/aidl.cpp#580
547 AidlError load_and_validate_aidl(
...
575 AidlDocument* parsed_doc = p.GetDocument();
576
577 unique_ptr<AidlInterface> interface(parsed_doc->ReleaseInterface());
578
579 if (!interface) {
580 LOG(ERROR) << "refusing to generate code from aidl file defining "
581 "parcelable";
582 return AidlError::FOUND_PARCELABLE;
583 }

Havok Vision Game Engine: Compiling Autodesk Scaleform For Android in Visual Studio

I've followed the instructions in the tutorial on Scaleform
http://www.projectanarchy.com/introduction-scaleform
On windows it all worked fine, but now I am trying to compile it for Android in Visual Studio 2010 and I get all these errors:
Error 1 error MSB6006: "C:\Android\NDK\android-ndk-r9d\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-g++.exe" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\hkAndroid\Microsoft.Cpp.hkAndroid.Targets 66 6 CounterUIApplication
and errors like this:
8 IntelliSense: cannot open source file "Vision/Runtime/EnginePlugins/ThirdParty/ScaleformEnginePlugin/VScaleformVariable.hpp" c:\game engineering projects\scaleformtry\scaleformcounterui\counterui\source\counteruiapplication\main.cpp 18 1 CounterUIApplication
and like this:
31 IntelliSense: identifier "VISION_PLUGIN_ENSURE_LOADED" is undefined c:\game engineering projects\scaleformtry\scaleformcounterui\counterui\source\counteruiapplication\main.cpp 99 3 CounterUIApplication
It seems that Visual Studio does not load the scaleform header files in the Android solution.
How do I fix it?
(Note: I've checked the Scaleform toggle box in the vGameSolutionCreator of the Vision Engine)
Thanks.
(I've asked this question already on Havok PA website but got no answer for a long time)
I've found the answer.
After sitting in front of my computer for 8 hours I've found that the problem was caused by the Windows specific line in my source code (hkvLog::FatalError is not supported on Android):
if(m_spMovie==NULL)
{
hkvLog::FatalError("Could not load movie: %s", m_sMovieName);
}
After I removed this line the program compiled with no problem and the apk was created.

mylib.so has text relocations. This is wasting memory and is a security risk. Please fix

My Android application (using native library) print this warning on Android 4.4 :
linker mylib.so has text relocations. This is wasting memory and is a security risk. Please fix.
Have you got an idea of what it is and how to fix it ?
Thanks,
This would appear to be a result of two ndk-gcc bugs mentioned at https://code.google.com/p/android/issues/detail?id=23203
and stated there to have been fixed as of ndk-r8c.
It would appear that the check for libraries with the issue has been added only recently.
Note: please do not edit this post to hide the link URL. It is explicit because the destination is what makes it authoritative.
Further Note Changing NDK versions is only a fix when the warning is due to the code of your application. It will have no effect if the warning is instead on a system component such as libdvm - that can only be fixed by a system update.
You need to make the code in your library position independent...add -fpic or -fPIC to your LOCALC_FLAGS in your Android.mk and you also need to ensure that you're not linking against any static or shared libraries that contain text relocations themselves. If they do and you can re-compile them, use one of the flags mentioned above.
In short, you need to compile your library with one of the -fpic or -fPIC flags, where PIC is an abbreviation for Position Independent Code.
The longer answer is that your yourlib.so has been compiled in a manner that does not conform to the Google Android standard for an ELF file, where this Dynamic Array Tag entry is unexpected. In the best case the library will still run, but it is still an error and future AOS version will probably not allow it to run.
DT_TEXTREL 0x16 (22)
To check whats in you library use something along the line of:
# readelf --wide -S yourlib.so
There are 37 section headers, starting at offset 0x40:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 0000000000000000 002400 068f80 00 AX 0 0 16
[ 2] .rodata PROGBITS 0000000000000000 06b380 05ad00 00 WA 0 0 32
...
[16] .rela.text RELA 0000000000000000 26b8e8 023040 18 14 1 8
...
[36] .rela.debug_frame RELA 0000000000000000 25a608 0112e0 18 14 27 8
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Please see my extensive answer on the topic, for more DT entry details. For details how to write proper dynamic libraries this is a must-read.
I got the same error with my application.
The application was using a native daemon that used a native library which was not implementing all the functions in its header file. When I added the required implementations to the native library everything just worked.
I don't know if you have the exact same issue but it just probably means the your native side has some mismatch.

Too many methods error

Apparently I have too many apache poi jars which return too many methods and go above the limit when I try to read and write an xlsx file. Below is the error I get
trouble writing output: Too many methods: 66024; max is 65536. By package:
13 java.lang
1 java.lang.reflect
5 java.util
1 javax.xml.namespace
66 org.apache.xmlbeans
19 org.apache.xmlbeans.impl.values
1 org.apache.xmlbeans.impl.xb.xmlschema
2500 org.openxmlformats.schemas.drawingml.x2006.chart
1430 org.openxmlformats.schemas.drawingml.x2006.chart.impl
8767 org.openxmlformats.schemas.drawingml.x2006.main
5258 org.openxmlformats.schemas.drawingml.x2006.main.impl
86 org.openxmlformats.schemas.drawingml.x2006.picture
33 org.openxmlformats.schemas.drawingml.x2006.picture.impl
Is there a way around this? I don't want to delete any libraries and yet my project is not compiling. Please help.
Found the issue!
It's Apache POI's XSSF incompatibility with Android! Actually Apache is pretty okay but when Android converts your Java code into Dalvik Executable files it has a method limit of 65536 which the libraries of Apache POI when they handle XSSF exceed. Hence the error. It has nothing to do with lines. :) I had only 75 rows and 7 columns. More information on this can be found at http://mail-archives.apache.org/mod_mbox/poi-dev/201110.mbox/%3CCA+JOeWNWinmNmEtHs5VK+KEc_6BzAG_=LfpdXqsDsnjJKR2X7Q#mail.gmail.com%3E.
short answer:
just remove the unnecessary jar files. e.g. from the list you gave, I saw there are '8767' methods from org.openxmlformats.schemas.drawingml.x2006.main , if it's not necessary, just remove this jar file and you life will be easier.
Detailed answer:
On titanium official Jira , this bug is still "reopened", created 1 year ago. I don't think they are releasing a new version tomorrow. ( https://jira.appcelerator.org/browse/TIMOB-18082 )
Removing the unnecessary jar files will cause the runtime error, however, since they are unnecessary, runtime error won't occur without them.
read the comments, also refer to here: ADT: fail to build when there are too many packages and classes
and here: Can we create multi dex support builds in Titanium android?

Categories

Resources