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
Related
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.
I use it like this:
devicePolicyManager
.resetPasswordWithToken(
componentName,
nonNullOrEmptyPassword,
nonNullOrEmptyByteArray,
0
)
And it throws NPE:
java.lang.NullPointerException: Attempt to get length of null array
at android.os.Parcel.createException(Parcel.java:2094)
at android.os.Parcel.readException(Parcel.java:2056)
at android.os.Parcel.readException(Parcel.java:2004)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.resetPasswordWithToken(IDevicePolicyManager.java:15625)
at android.app.admin.DevicePolicyManager.resetPasswordWithToken(DevicePolicyManager.java:3959)
Android 10, Samsung A51, app is a device owner. What's wrong?
Probaby internal implementation sets the token to null if the user is not admin on the device. Check what isResetPasswordTokenActive() returns.
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
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.
I noticed that sometimes, not sure in which conditions, while downloading an image using Universal-Image-Loader (https://github.com/nostra13/Android-Universal-Image-Loader), I get the following NullPointerException:
E/ImageLoader(27386): Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
E/ImageLoader(27386): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference
E/ImageLoader(27386): at com.android.okhttp.internal.http.StatusLine.<init>(StatusLine.java:24)
E/ImageLoader(27386): at com.android.okhttp.Response$Builder.statusLine(Response.java:419)
E/ImageLoader(27386): at com.android.okhttp.internal.http.JavaApiConverter.createOkResponse(JavaApiConverter.java:116)
E/ImageLoader(27386): at com.android.okhttp.internal.http.ResponseCacheAdapter.get(ResponseCacheAdapter.java:53)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:269)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
E/ImageLoader(27386): at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
E/ImageLoader(27386): at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromNetwork(BaseImageDownloader.java:113)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:84)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:290)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:273)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:229)
E/ImageLoader(27386): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
E/ImageLoader(27386): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/ImageLoader(27386): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/ImageLoader(27386): at java.lang.Thread.run(Thread.java:818)
This seems like a bug in okhttp, not in Universal-Image-Loader. The code does something like this, and it crashes in the call to getResponseCode:
String encodedUrl = Uri.encode(url, ALLOWED_URI_CHARS);
HttpURLConnection conn = (HttpURLConnection) new URL(encodedUrl).openConnection();
conn.getResponseCode()
I managed to work around this by disabling cache on the connection before calling getResponseCode:
conn.setUseCaches(false);
Does anyone have an idea why this happens and in which exact conditions? Can this be something related to server settings, perhaps something to do with caching?
The cause for this is a custom implementation of ResponseCache. When implementing CacheResponse.getHeaders(), you need to put the status line in the null key of the multimap. See: http://developer.android.com/reference/java/net/CacheResponse.html#getHeaders().
Failing to do so, causes okhttp to fail with a NullPointerException, which is a bug in okhttp.
I'm copying the full explanation from the okhttp issue tracker at https://code.google.com/p/android/issues/detail?id=160522#c5, as google code is about to close...
There's some strangeness in the HttpURLConnection APIs around the status line. When I implemented the ResponseCacheAdapter / JavaApiConverter I did so assuming certain behavior, where the behavior is sometimes poorly specified in the JavaDocs.
The root cause is that Android assumes that the status line (e.g. the part of the response that indicates the response code, a message) is held as the header with a null key. This is alluded to in the API docs when you look at the header with the index of zero, but is not explicit in the methods that return the Map, or that take a String.
See here: http://developer.android.com/reference/java/net/URLConnection.html#getHeaderFields()
And: http://developer.android.com/reference/java/net/CacheResponse.html#getHeaders()
OkHttp's HttpURLConnection implementation does this, and it has been the case on Android for many releases.
This code:
https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/util/TiResponseCache.java#L416
suggests the cache implementation won't deal properly with a response header with a null key. The header with a null key is being written out as being a header with the key with a string "null", so it is not round-tripped. When the cached headers are deserialized we end up without a header with a null key, which means the OkHttp code is not able to reconstruct the status line from the CacheResponse.