Stock Android : NPException : at android.content.res.StringBlock.get(int) - android

SO users, please read fully then decide to mark the Duplicate for NullPointer exception.
While app launch, from ApplicationExt(extends Application), we initialize the thread in which load the CSV file from Resource bundle(RawSource). It always works on many of the devices. But get crashed on below device for the very first time. For the second time, it gets loaded from the bundle.
OS version : Lollipop (5.1.1)
Device : OnePlus A0001
Crash Log:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
at android.content.res.AssetManager.getResourceValue(AssetManager.java:213)
at android.content.res.Resources.getValue(Resources.java:1334)
at android.content.res.Resources.getValue(Resources.java:1323)
at android.content.res.Resources.openRawResource(Resources.java:1242)
at android.content.res.Resources.openRawResource(Resources.java:1219)
at com.xxxx.yyyy.network.NetworkManager.getBrandCodesFromCsvFile(NetworkManager.java:2961)
at com.xxxx.yyyy.network.NetworkManager.getBrandCodes(NetworkManager.java:3221)
at com.xxxx.yyyy.network.NetworkManager.checkAndUpdateMobileCodeFromBundle(NetworkManager.java:3110)
at com.xxxx.yyyy.OurApplication$1.run(OurApplication.java:132)
at java.lang.Thread.run(Thread.java:818)
Code Snippet:
In Application, onCreate(...),
Create a thread with code of csv load
Run the thread at the end of onCreate -> new Thread(ourThread).start();
Exact crash on this line :
InputStream bundleStream = OurApplicationClass.getContext().getResources().openRawResource(sourceId);
Note:
I've found related issue on Github. https://github.com/osmandapp/Osmand/issues/2575. But unable to confirm whether it's working for my case.

Related

MediaProjectionManager.getMediaProjection( ) problem in android 12

I create a screenshot application and that work good in all of the android devices.
But I have a problem with take screenshot in android 12 (Xiaomi 11t) I'm using static intent and result code and then clone intent and pass it to this function mediaProjectionManager.getMediaProjection(resultCode,clonedIntent) I have no problem with take screen shot for first time but I can't take screen shot for second time and I get this error.
if you need more info please tell me.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.koala.classor, PID: 10824
java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Set.add(java.lang.Object)' on a null object reference
at android.os.Parcel.createExceptionOrNull(Parcel.java:2431)
at android.os.Parcel.createException(Parcel.java:2409)
at android.os.Parcel.readException(Parcel.java:2392)
at android.os.Parcel.readException(Parcel.java:2334)
at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:235)
at android.media.projection.MediaProjection.<init>(MediaProjection.java:59)
at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:119)
at com.koala.classor.G.getMediaProjection(G.java:86)
at com.koala.classor.OverScreenWindowService$2$1.run(OverScreenWindowService.java:194)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8105)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:553)
at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:137)
at android.os.Binder.execTransactInternal(Binder.java:1182)
at android.os.Binder.execTransact(Binder.java:1146)
MIUI13+Android12
The RemoteException error is reported on line 553 of MediaProjectionManagerService. After checking the source code, the error message is that the package for applying for mediaprojection cannot be found.
It is guessed that MIUI maintains a separate list for this, only the package that has applied for permission will be in it, and it will be removed after obtaining and closing mediaprojection. No such mechanism has been seen in other systems.
In other words, intent data cannot be reused. The solution is also very simple, just don’t close the mediaprojection after using it.

FusedLocationApi.requestLocationUpdates failed

I have a form that I open in a webview in my app, after I complete it, it will appear a button that will let me download a pdf andd open it but when I do this I keep getting the next error:
OneSignal: FusedLocationApi.requestLocationUpdates failed!
java.lang.NullPointerException: Calling thread must be a prepared Looper thread.
at com.google.android.gms.common.internal.Preconditions.checkNotNull(com.google.android.gms:play-services-basement##17.6.0:2)
at com.google.android.gms.internal.location.zzz.requestLocationUpdates(com.google.android.gms:play-services-location##18.0.0:4)
at com.onesignal.GMSLocationController$FusedLocationApiWrapper.requestLocationUpdates(GMSLocationController.java:198)
at com.onesignal.GMSLocationController$LocationUpdateListener.init(GMSLocationController.java:181)
at com.onesignal.GMSLocationController$LocationUpdateListener.<init>(GMSLocationController.java:165)
at com.onesignal.GMSLocationController.onFocusChange(GMSLocationController.java:117)
at com.onesignal.LocationController.onFocusChange(LocationController.java:326)
at com.onesignal.OneSignal.onAppLostFocus(OneSignal.java:1308)
at com.onesignal.ActivityLifecycleHandler$AppFocusRunnable.run(ActivityLifecycleHandler.java:279)
at java.lang.Thread.run(Thread.java:923)
The button will appear in the webview. I think I get that error because I open the pdf on the main thread.

React-native / Expo: Attempt to invoke virtual method on a null object reference message error

I'm trying to get my MongoDB database linked to my front react-native app, and I can't get rid of this error message when I run the app with Expo: "Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference".
I think my error occurs in the 'then function' right after my axios request:
getConnected = () => {
console.log('still ok');
axios.get(`api/signin/${this.state.email}/${this.state.password}`)
.then(function(res) {
console.log('Fetching data');
}.bind(this))
.catch(error => {
console.log(error.res);
});
}
I've created a proxy in the package.json in order to link the database to the app, I'm not sure this is the right way to do it. I'm a beginner!
Can someone help me figure out what I'm doing wrong here?
Let me know if you need further details.
Thanks!
Error screenshot
I've just had this problem a minute ago. It seems if the URL is invalid, you will get this error.
For my folder set up I had something like app.js and a folder called api, with a file called api.json. You cannot fetch the folder from here like you would with a html application. For example
fetch("./api/api.json")
The above would return the error you are getting.
You need to use the Assets system.
https://docs.expo.io/versions/latest/guides/assets

Codename one crash during capture audio

I'm getting a crash on our app on a part that used to work:
a call to Capture.captureAudio() to get the path to a newly recorded audio file.
I've tested on android and I get this stack trace:
[EDT] 0:5:30,336 - Exception: java.lang.NullPointerException - Attempt to invoke interface method 'int android.database.Cursor.getColumnIndexOrThrow(java.lang.String)' on a null object reference
java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getColumnIndexOrThrow(java.lang.String)' on a null object reference
at com.codename1.impl.android.AndroidImplementation.convertImageUriToFilePath(AndroidImplementation.java:5197)
at com.codename1.impl.android.AndroidImplementation.onActivityResult(AndroidImplementation.java:4936)
at com.codename1.impl.android.CodenameOneActivity$9.run(CodenameOneActivity.java:506)
at com.codename1.ui.Display.processSerialCalls(Display.java:1150)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1094)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1204)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1242)
at com.codename1.capture.Capture.captureAudio(Capture.java:95)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler.lambda$run$11(AudioTaskListener.java:86)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler.access$lambda$0(AudioTaskListener.java)
at com.handover.app.taskhandlers.AudioTaskListener$AudioShowHandler$$Lambda$1.actionPerformed(Unknown Source)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:362)
at com.codename1.ui.Button.fireActionEvent(Button.java:411)
at com.codename1.ui.Button.released(Button.java:442)
at com.codename1.ui.Button.pointerReleased(Button.java:530)
at com.codename1.ui.Form.pointerReleased(Form.java:2613)
at com.codename1.ui.Form.pointerReleased(Form.java:2549)
at com.codename1.ui.Component.pointerReleased(Component.java:3147)
at com.codename1.ui.Display.handleEvent(Display.java:2024)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1066)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1204)
at com.codename1.ui.Display.invokeAndBlock(Display.java:1242)
at com.codename1.ui.AnimationManager.addAnimationAndBlock(AnimationManager.java:105)
at com.codename1.ui.Container.animateHierarchy(Container.java:2465)
at com.codename1.ui.Container.animateHierarchyAndWait(Container.java:2185)
at com.handover.app.ui.components.ToastNotification.setVisible(ToastNotification.java:782)
at com.handover.app.ui.components.ToastNotification.updateStatus(ToastNotification.java:530)
at com.handover.app.ui.components.ToastNotification.removeStatus(ToastNotification.java:738)
at com.handover.app.ui.components.ToastNotification.access$700(ToastNotification.java:82)
at com.handover.app.ui.components.ToastNotification$Status.clear(ToastNotification.java:380)
at com.handover.app.ui.components.NetworkProgressIndicator.actionPerformed(NetworkProgressIndicator.java:55)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at com.codename1.ui.util.EventDispatcher.access$100(EventDispatcher.java:45)
at com.codename1.ui.util.EventDispatcher$CallbackClass.run(EventDispatcher.java:95)
at com.codename1.ui.Display.processSerialCalls(Display.java:1150)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1094)
at com.codename1.ui.Display.mainEDTLoop(Display.java:995)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
at java.lang.Thread.run(Thread.java:831)
It has been a while since this part of the app was throughly tested, and I'm not entirly sure which version of CN1 this was working on.
Capture.capturePhoto() and Capture.captureVideo() are both still working as expected.
This should be fixed in current versions of the Android build

What are the list of Android specific exceptions?

I know some of exceptions are thrown by Android framework. Like ActivityNotFoundException, WindowManager.BadTokenException.
But i am not aware of all other exceptions which are specific to android framework.
Can anybody list possible Android framework specific exceptions with a small description. Or suggest me blogs information which contains the required information.
http://developer.android.com/reference/java/lang/Exception.html
I think here you can find it, "Known Indirect Subclasses", totally 224 exceptions.
Only choose the one started by "Android", here are about 72 exceptions, these should be the list
android.content.ActivityNotFoundException
android.util.AndroidRuntimeException
android.accounts.AuthenticatorException
android.os.BadParcelableException
android.util.Base64DataException
android.hardware.camera2.CameraAccessException
android.database.CursorIndexOutOfBoundsException
android.os.DeadObjectException
android.media.DeniedByServerException
android.support.v4.app.Fragment.InstantiationException
android.opengl.GLException
android.view.InflateException
android.content.IntentFilter.MalformedMimeTypeException
android.content.IntentSender.SendIntentException
android.view.KeyCharacterMap.UnavailableException
android.security.keystore.KeyExpiredException
android.security.keystore.KeyNotYetValidException
android.security.keystore.KeyPermanentlyInvalidatedException
android.util.MalformedJsonException
android.media.MediaCodec.CodecException
android.media.MediaCodec.CryptoException
android.media.MediaDrm.MediaDrmStateException
android.media.MediaDrmResetException
android.accounts.NetworkErrorException
android.os.NetworkOnMainThreadException
android.util.NoSuchPropertyException
android.media.NotProvisionedException
android.support.v4.os.OperationCanceledException
android.content.pm.PackageManager.NameNotFoundException
android.os.ParcelFileDescriptor.FileDescriptorDetachedException
android.os.ParcelFormatException
android.net.ParseException
android.app.PendingIntent.CanceledException
android.support.v8.renderscript.RSDriverException
android.support.v8.renderscript.RSIllegalArgumentException
android.support.v8.renderscript.RSInvalidStateException
android.support.v8.renderscript.RSRuntimeException
android.content.ReceiverCallNotAllowedException
android.os.RemoteException
android.widget.RemoteViews.ActionException
android.media.ResourceBusyException
android.content.res.Resources.NotFoundException
android.database.SQLException
android.database.sqlite.SQLiteAbortException
android.database.sqlite.SQLiteAccessPermException
android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException
android.database.sqlite.SQLiteBlobTooBigException
android.database.sqlite.SQLiteCantOpenDatabaseException
android.database.sqlite.SQLiteConstraintException
android.database.sqlite.SQLiteDatabaseCorruptException
android.database.sqlite.SQLiteDatabaseLockedException
android.database.sqlite.SQLiteDatatypeMismatchException
android.database.sqlite.SQLiteDiskIOException
android.database.sqlite.SQLiteDoneException
android.database.sqlite.SQLiteException
android.database.sqlite.SQLiteFullException
android.database.sqlite.SQLiteMisuseException
android.database.sqlite.SQLiteOutOfMemoryException
android.database.sqlite.SQLiteReadOnlyDatabaseException
android.database.sqlite.SQLiteTableLockedException
android.provider.Settings.SettingNotFoundException
android.database.StaleDataException
android.view.Surface.OutOfResourcesException
android.view.SurfaceHolder.BadSurfaceTypeException
android.nfc.TagLostException
android.util.TimeFormatException
android.os.TransactionTooLargeException
android.media.UnsupportedSchemeException
android.security.keystore.UserNotAuthenticatedException
android.view.WindowManager.BadTokenException
android.view.WindowManager.LayoutParams#token
android.view.WindowManager.InvalidDisplayException
The following are the exceptions that are supported by Android:
1.) InflateException : This exception is thrown When an error conditions are occurred.
2.) Surface.OutOfResourceException: This exception is thrown When a surface is not created or resized.
3.) SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS
4.) WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.

Categories

Resources