Qoppa PDF Android NullPointer - android

I`m trying qoppapdf in my App and it runs into an NullPointer in the following code:
PDFDocument pdf = null;
try {
pdf = new PDFDocument(url, null);
} catch (PDFException e) {
e.printStackTrace();
}
PDFPage page = pdf.getPage(0);
The error reads:
06-01 17:29:59.687 24761-24761/app W/dalvikvm﹕ Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/qoppa/android/pdfProcess/PDFPage;
06-01 17:29:59.687 24761-24761/app D/AndroidRuntime﹕ Shutting down VM
06-01 17:29:59.687 24761-24761/app W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x413d22a0)
06-01 17:29:59.757 24761-24763/app D/dalvikvm﹕ GC_CONCURRENT freed 2569K, 26% free 10659K/14343K, paused 4ms+13ms, total 68ms
06-01 17:29:59.757 24761-24761/app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.qoppa.android.pdfProcess.PDFDocument$1.b(Unknown Source)
at com.qoppa.android.pdfViewer.e.p.b(Unknown Source)
at com.qoppa.android.pdfProcess.PDFDocument.b(Unknown Source)
at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)
at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)
at com.qoppa.android.pdfProcess.PDFDocument.<init>(Unknown Source)
The url which is used as input is valid and works fine with other PDF-Viewer.
Does anyone experienced this or similar problems? Am I doing it wrong?
I would be pleased to hear from you :-)

Please add the following code before loading the document:
//this static allows the sdk to access font assets,
//it must be set prior to utilizing libraries
StandardFontTF.mAssetMgr = getAssets();

Related

java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp

Receiving this error on Android 4.4 device when starting my app. App immediately crashes. However I don't have this error on Android 5.1 device. Any clue?
10-15 22:35:06.306 14072-14072/com D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
10-15 22:35:06.306 14072-14072/com D/AndroidRuntime﹕ Shutting down VM
10-15 22:35:06.306 14072-14072/com W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4304b160)
10-15 22:35:06.306 14072-14072/com E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process:com., PID: 14072
java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp
at com.google.android.gms.measurement.internal.zzz.zzj(Unknown Source)
at com.google.android.gms.measurement.internal.zzv.(Unknown Source)
at com.google.android.gms.measurement.internal.zzz.zzAq(Unknown Source)
at com.google.android.gms.measurement.internal.zzv.zzaL(Unknown Source)
at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at android.app.ActivityThread.installProvider(ActivityThread.java:4830)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4425)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4365)
at android.app.ActivityThread.access$1500(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5061)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
at dalvik.system.NativeStart.main(Native Method)
needed to add this in class that extends Application:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
EDIT: I noticed this answer is becoming more popular so please note my comment on the question:
"ATTENTION To anybody reading this though! The real problem was that I was using the ENTIRE google play services framework which was forcing me into multi dex. Avoid multi dex if you can because it slows down builds. Only bring in what you need from google play services. So instead of putting "compile 'com.google.android.gms:play-services:8.1.0'", put "compile 'com.google.android.gms:play-services-location:8.1.0'" for example."
For those who have already activated MultiDex and still get this exception, it's just a stupid Android Studio / Gradle issue.
Try cleaning project, toggling Instant Run in settings, and rebuilding the project.
I had the error and i resolved it by updating the gms play-service to the latest version.

Android BinderInternal.getContextObject:()Landroid/os/IBinder running app via adb

I am trying to run a java app via adb using dalvikvm -cp. It works in case of simple apps, but as soon as I want to use android native classes, e.g. do this (and include the android.jar in the classpath of javac to handle dependencies):
import android.view.KeyCharacterMap;
...
KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
and run the app from adb using dalvikvm -cp I get this error:
java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.getContextObject:()Landroid/os/IBinder;
at com.android.internal.os.BinderInternal.getContextObject(Native Method)
at android.os.ServiceManager.getIServiceManager(ServiceManager.java:39)
at android.os.ServiceManager.getService(ServiceManager.java:55)
at android.hardware.input.InputManager.getInstance(InputManager.java:187)
at android.view.KeyCharacterMap.load(KeyCharacterMap.java:331)
And in logcat:
java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.getContextObject:()Landroid/os/IBinder;
at com.android.internal.os.BinderInternal.getContextObject(Native Method)
at android.os.ServiceManager.getIServiceManager(ServiceManager.java:39)
at android.os.ServiceManager.getService(ServiceManager.java:55)
at android.hardware.input.InputManager.getInstance(InputManager.java:187)
at android.view.KeyCharacterMap.load(KeyCharacterMap.java:331)
W/dalvikvm(22137): No implementation found for native Lcom/android/internal/os/BinderInternal;.getContextObject:()Landroid/os/IBinder;
W/dalvikvm(22137): threadid=1: thread exiting with uncaught exception (group=0x4092f2a0)
D/dalvikvm(22137): GC_CONCURRENT freed 19K, 89% free 118K/1024K, paused 0ms+0ms, total 1ms
W/dalvikvm(22137): No implementation found for native Lcom/android/internal/os/BinderInternal;.handleGc:()V
E/System (22137): Uncaught exception thrown by finalizer
E/System (22137): java.lang.UnsatisfiedLinkError: Native method not found: com.android.internal.os.BinderInternal.handleGc:()V
E/System (22137): at com.android.internal.os.BinderInternal.handleGc(Native Method)
E/System (22137): at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:45)
E/System (22137): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186)
E/System (22137): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
E/System (22137): at java.lang.Thread.run(Thread.java:856)
I looked at sources of apps such as am or input and they successfully use binding, so what should I do to use it in my adb java app?

Errors related to Android NDK

Running this in my android device gives me these errors.
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lffvideolivewallpaper/frankandrobot/com/NativeCalls;
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40ed42a0)
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onSharedPreferenceChanged(VideoLiveWallpaper.java:144)
at ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper.onCreate(VideoLiveWallpaper.java:78)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load avcore: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at ffvideolivewallpaper.frankandrobot.com.NativeCalls.(NativeCalls.java:42)
... 13 more
I think these errors are related to Android NDK. Can anyone guide me on this, keeping in mind that I have no prior knowledge of Android NDK and how it works.
This may happen if we install the app on a device where the previous version was already installed we always get this kind of error:
Just look at this similar problem : https://groups.google.com/d/topic/android-ndk/YmKly4zEMQ0/discussion
I found the reason why I was getting this error, because I did not build the native libraries. I used ndk-build and the errors got resolved.

Android - Parsing large files using SAX parser

I am trying to parse the xml data coming from webservice using SAX parser, when i try to parse the data(size:7.4MB) using URL, it works fine but when I copy the xml data from the URL and place the xml file(size:7.4MB) in the raw folder, the parsing fails.
When the size of file placed in raw folder is reduced to 1.95MB, it works fine. I have tried shuffling the tags to check if there are any issues with the data, I haven't found any.It works fine as long as the size doesn't exceed 1.95MB. Is there any size limit while parsing the data from raw folder in android? if yes what is the limit? or How to parse the large files using SAX parser?
Any pointers will really help me. Thanks in advance for your time and any help offered.
Regards,
Ramesh
02-14 17:35:35.651: DEBUG/asset(11035): Data exceeds UNCOMPRESS_DATA_MAX (2138421 vs 2097152)
02-14 17:35:35.651: WARN/dalvikvm(11035): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0)
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): FATAL EXCEPTION: Thread-13
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): java.lang.AssertionError: java.io.IOException
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): at android.util.Xml.parse(Xml.java:89)
code
try {
System.out.println("1");
//Xml.parse((url.openConnection().getInputStream()), Encoding.UTF_8, datahandler);
Xml.parse(getResources().openRawResource(R.raw.sample), Encoding.UTF_8, datahandler);
System.out.println("2");
//xr.parse(new InputSource(getAssets().open("sample.xml")));
}catch(Exception e){
System.out.println("Ramesh"+"XML Parsing exception:"+e);
}
error
Android DEBUG/asset(11035): Data exceeds UNCOMPRESS_DATA_MAX (2138421 vs 2097152)
WARN/dalvikvm(11035): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0)
ERROR/AndroidRuntime(11035): FATAL EXCEPTION: Thread-13
ERROR/AndroidRuntime(11035): java.lang.AssertionError: java.io.IOException
ERROR/AndroidRuntime(11035): at android.util.Xml.parse(Xml.java:89)
ERROR/AndroidRuntime(11035): at com.infosys.gss.ui.Login$2$1.run(Login.java:431)
ERROR/AndroidRuntime(11035): Caused by: java.io.IOException

JTwitter VerifyError in Android pre-2.0

I'm attempting to integrate JTwitter into an Android application, and I have been completely successful up until the point where I decided to regression test on older Android versions. In Android 2.x my code works great, but in Android 1.5/1.6 Dalvik throws a VerifyError on the following line:
OAuthSignpostClient oauthClient
= new OAuthSignpostClient(KEY_TWITTER, SECRET_TWITTER, "oob");
and provides this logcat output and stack trace:
Could not find method javax.swing.JOptionPane.showInputDialog, referenced from method winterwell.jtwitter.OAuthSignpostClient.askUser
VFY: unable to resolve static method 1703: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Object;)Ljava/lang/String;
VFY: rejecting opcode 0x71 at 0x0000
VFY: rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/String;
Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
at com.wirelessdesigns.android.AuthActivity.onCreate(AuthActivity.java:37)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.access$2100(ActivityThread.java:116)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4203)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
at dalvik.system.NativeStart.main(Native Method)
I'm trying to figure out what may have changed in the underlying implementation between the Android versions that would affect this and what the workaround might be? A similar question was answered a while back, but the answer was in the form of a now-dead link to a forum post.
Any thoughts?
Before Android 2.0, the verifier would immediately reject classes when something wasn't right. In 2.0 and later, reporting of certain failures is deferred until the code is actually executed. Attempting to call a nonexistent or inaccessible method is one such case.
This is an example of why the verifier behavior was changed. Even though you're not calling the absent function, the whole class that's trying to call it is getting rejected.
Some workarounds can be found here, but it sounds like you've found one on your own.

Categories

Resources