How do I fix an ANR handler throwing an exception? - android

I am debugging using an actual phone, and sometimes I am inspecting the contents of an Intent (which naturally arrives on the main thread) in the debugger. However, since I am blocking the main thread, the system throws an ANR. Afterwards, the app crashes and I see this in LogCat:
Here is the exception:
07-25 12:25:32.058 673-15203/system_process E/ActivityManager﹕ Error reading /data/anr/traces.txt
java.io.FileNotFoundException: /data/anr/traces.txt: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at android.os.FileUtils.readTextFile(FileUtils.java:159)
at com.android.server.am.ActivityManagerService$15.run(ActivityManagerService.java:8926)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:393)
            at java.io.FileInputStream.<init>(FileInputStream.java:78)
            at android.os.FileUtils.readTextFile(FileUtils.java:159)
            at com.android.server.am.ActivityManagerService$15.run(ActivityManagerService.java:8926)
Terminal shows that the file is actually not there. If I try and create it myself, it just gets deleted and the exception is still thrown. There is actually a different file: traces_com.foo.bar.txt. Maybe it is supposed to be looking for that, but isnt for some reason?

Related

Xamarain Forms file read permissions issue on Android. ENOENT (No such file or directory). Only happens for some users

I've got a Xamarin.Forms app on the Google Play store for changing the pitch and speed of music and video. Its got a file read permissions problem on Android, but only for some users (stack trace shown below). I've set the external storage read permission:
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
in the manifest.
For the majority of users, all is working correctly when selecting an audio/video file. But I'm getting notified via Rollbar https://rollbar.com/ of the file permissions issues for some users in android versions 8-11.
I'm using the https://www.nuget.org/packages/Xamarin.Plugin.FilePicker/ plugin to browse for music/video files in my app.
Rollbar error notification from my app:
Java.IO.FileNotFoundException: /storage/emulated/0/Download/Kev Hlub Tu Tag Nag Hmo (Lyric).mp4: open failed: ENOENT (No such file or directory) ---> Android.Systems.ErrnoException: open failed: ENOENT (No such file or directory)
Stack trace:
Java.IO.FileNotFoundException: /storage/emulated/0/Download/Kev Hlub Tu Tag Nag Hmo (Lyric).mp4: open failed: ENOENT (No such file or directory) ---> Android.Systems.ErrnoException: open failed: ENOENT (No such file or directory)
--- End of inner exception stack trace ---
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <24e422c426e0468ca1fd74b59870ff08>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <24e422c426e0468ca1fd74b59870ff08>:0
at Android.Media.MediaPlayer.SetDataSource (Android.Content.Context context, Android.Net.Uri uri) [0x00053] in <4586a87d34754df7a521e11e2fd22040>:0
at FormsVideoLibrary.Droid.VideoPlayerRenderer.SetSource () [0x0003e] in <01a54421e2d344a3a06c7dbb0d52b8a1>:0
--- End of managed Java.IO.FileNotFoundException stack trace ---
java.io.FileNotFoundException: /storage/emulated/0/Download/Kev Hlub Tu Tag Nag Hmo (Lyric).mp4: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:492)
at java.io.FileInputStream.<init>(FileInputStream.java:160)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1259)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1230)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1147)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1072)
at crc646e83aba39dfdd46d.VideoPlayerRenderer.n_surfaceCreated(Native Method)
at crc646e83aba39dfdd46d.VideoPlayerRenderer.surfaceCreated(VideoPlayerRenderer.java:70)
at android.view.SurfaceView.updateSurface(SurfaceView.java:1284)
at android.view.SurfaceView$1.onPreDraw(SurfaceView.java:225)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1124)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3854)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2618)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9971)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010)
at android.view.Choreographer.doCallbacks(Choreographer.java:809)
at android.view.Choreographer.doFrame(Choreographer.java:744)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8373)
at libcore.io.IoBridge.open(IoBridge.java:478)
... 24 more
My App on Google Play:
https://play.google.com/store/apps/details?id=com.darceysoft.mavsc&hl=en&gl=US
Thanks in advance for any help on this.
Cheers,
Wayne

Android Emulator Black screen -

Application worked on this emulator, I have tried to implement Google Play Game services and it appears that this service can't connect. I have tried on multiple emulators. Now when I run the app all I get is the black screen.
Here is the Android Monitor:
09-18 13:11:28.507 1141-1141/? E/Drm: Failed to open plugin directory /vendor/lib/mediadrm
09-18 13:11:29.897 1963-8847/com.google.android.gms E/ChromeSync: [Sync,SyncAdapter] Failed to sync.
hlr: Error when calling the server (message: Application credential header not valid. Please fix the client to pass a valid application credential header.).
at hlt.b(:com.google.android.gms:11)
at hmd.c(:com.google.android.gms:1)
at hmh.b(:com.google.android.gms:61)
at hmf.a(:com.google.android.gms:12)
at jlo.onPerformSync(:com.google.android.gms:2)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
Caused by: aury: INVALID_ARGUMENT: Application credential header not valid. Please fix the client to pass a valid application credential header.
at auru.c(:com.google.android.gms:2)
at jgq.a(:com.google.android.gms:62)
at hlt.b(:com.google.android.gms:9)
at hmd.c(:com.google.android.gms:1) 
at hmh.b(:com.google.android.gms:61) 
at hmf.a(:com.google.android.gms:12) 
at jlo.onPerformSync(:com.google.android.gms:2) 
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259) 
09-18 13:11:41.977 8863-8863/? E/memtrack: Couldn't load memtrack module (No such file or directory)
09-18 13:11:41.977 8863-8863/? E/android.os.Debug: failed to load memtrack module: -2
09-18 13:11:42.887 1963-1972/com.google.android.gms E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:179)
at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:168)
at android.os.ParcelFileDescriptor.createPipe(ParcelFileDescriptor.java:362)
at com.google.android.gms.ads.internal.request.n.a(:com.google.android.gms:1)
at com.google.android.gms.ads.internal.request.n.writeToParcel(:com.google.android.gms:5)
at jdq.a(:com.google.android.gms:16)
at com.google.android.gms.ads.internal.request.d.writeToParcel(:com.google.android.gms:28)
at brr.a(:com.google.android.gms:6)
at com.google.android.gms.ads.internal.request.k.a(:com.google.android.gms:0)
at com.google.android.gms.ads.internal.request.service.i.run(:com.google.android.gms:7)
at com.google.android.gms.ads.internal.util.v.call(:com.google.android.gms:1)
at com.google.android.gms.ads.internal.util.w.run(:com.google.android.gms:0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
09-18 13:11:42.957 1816-2482/com.google.process.gapps E/NetworkScheduler.SR: Unrecognised action provided: android.intent.action.PACKAGE_REMOVED
09-18 13:11:43.397 8903-8903/? E/memtrack: Couldn't load memtrack module (No such file or directory)
Also I tried to install signed apk to Emulator with adb install but the same problem appears.

Facebook login promblem in my app

Here is the stacktrace:
08-04 11:14:20.035 31839-31839/datinglove.co.in E/Zygote: Zygote: error closing descriptor
libcore.io.ErrnoException: close failed: EBADF (Bad file number)
at libcore.io.Posix.close(Native Method)
at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:198
at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:662)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
at dalvik.system.NativeStart.main(Native Method)
Once check internet Permission with app.
Have you used any third part library in app ?

Error while uploading file from Android to Node Server "Permission denied"

I am trying to use an Android app to upload a file to a node js server on my laptop. While it works fine with html, when trying to do the same in Andorid I get the following error.
The server is a simple Node server which seems to be working fine when I use other methods of posting files.
Error in upload with ID: 10ff84ba-0768-4423-a955-7a1a4f68d1aa. /init.rc: open failed: EACCES (Permission denied)
java.io.FileNotFoundException: /init.rc: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at com.alexbbb.uploadservice.BinaryUploadFile.getStream(BinaryUploadFile.java:34)
at com.alexbbb.uploadservice.BinaryUploadTask.writeBody(BinaryUploadTask.java:29)
at com.alexbbb.uploadservice.HttpUploadTask.upload(HttpUploadTask.java:131)
at com.alexbbb.uploadservice.HttpUploadTask.run(HttpUploadTask.java:65)
at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:127)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
at java.io.FileInputStream.<init>(FileInputStream.java:76) 
at com.alexbbb.uploadservice.BinaryUploadFile.getStream(BinaryUploadFile.java:34) 
at com.alexbbb.uploadservice.BinaryUploadTask.writeBody(BinaryUploadTask.java:29) 
at com.alexbbb.uploadservice.HttpUploadTask.upload(HttpUploadTask.java:131) 
at com.alexbbb.uploadservice.HttpUploadTask.run(HttpUploadTask.java:65) 
at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:127) 
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.os.HandlerThread.run(HandlerThread.java:61) 
01-01 08:17:17.382 20517-25217/jorc.com.fileupload2 W/com.alexbbb.uploadservice.BinaryUploadTask: Error in uploadId 5d59b0bb-5f5f-4926-b17d-87a8e408af4f on attempt 1. Waiting 1s before next attempt java.io.FileNotFoundException: /init.rc: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at com.alexbbb.uploadservice.BinaryUploadFile.getStream(BinaryUploadFile.java:34)
at com.alexbbb.uploadservice.BinaryUploadTask.writeBody(BinaryUploadTask.java:29)
at com.alexbbb.uploadservice.HttpUploadTask.upload(HttpUploadTask.java:131)
at com.alexbbb.uploadservice.HttpUploadTask.run(HttpUploadTask.java:65)
at com.alexbbb.uploadservice.UploadService.onHandleIntent(UploadService.java:127)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
Trying later I get the following confirmation from logcat but still no file is uploaded to my server:
01-01 08:57:43.032 1837-1837/jorc.com.fileupload2 I/UploadServiceDemo: Upload with ID 2b47d6b5-7bf6-4cf0-aeec-462b20c40ffd is completed: 200, <!DOCTYPE html>
<html>
<head>
<title>File Uploader</title>
<link href="app.css" rel="stylesheet">
</head>
It seems you are using this repo from githib:
https://github.com/alexbbb/android-upload-service
in this case go to MainActivity.java file and add
.addHeader("X-Parse-Application-Id", "your_key")
.addHeader("X-Parse-REST-API-Key", "your_key2")
under
.addHeader("file-name", new File(fileToUploadPath).getName())
That's all you need to see your file being uploaded to parse.com.
To make it easier on device add this:
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage(serverResponseMessage);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
Under this which shows you the uploaded file URL.
public void onCompleted(String uploadId, int serverResponseCode, String serverResponseMessage) {
progressBar.setProgress(0);
It is clearly written in your logcat Permission denied, you need to give READ permission in your manifest.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Invalid Filepath on TmxMapLoader.load()

I am following a youtube tutorial on how to make an android (probably not but I can hope for compatability) and iOS game using LibGDX and I have encountered a problem accessing a .tmx file from my res folder.
tileMap = new TmxMapLoader().load("res/level1.tmx");
using the above code I figured that the application would find my .tmx file in my res folder but I must be giving it incorrect information on how to find a file I have open in another tab. here is a screenshot of the search method called by hitting shift twice. http://imgur.com/PYd9Y5T
I see the file in the search method, but no matter what I seem to type in I cannot find level1.tmx
01-24 20:14:01.717 10013-10040/com.mac.elevator.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 60898
Process: com.mac.elevator.android, PID: 10013
com.badlogic.gdx.utils.SerializationException: Error parsing file: res/level1.tmx
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:83)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:92)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:80)
at com.mac.elevator.com.mac.elevator.states.Play.<init>(Play.java:91)
at com.mac.elevator.handlers.GameStateManager.getState(GameStateManager.java:35)
at com.mac.elevator.handlers.GameStateManager.pushState(GameStateManager.java:45)
at com.mac.elevator.handlers.GameStateManager.<init>(GameStateManager.java:22)
at com.mac.elevator.Game.create(Game.java:46)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1521)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: res/level1.tmx (Internal)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
at com.badlogic.gdx.files.FileHandle.reader(FileHandle.java:163)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:81)
            at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:92)
            at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:80)
            at com.mac.elevator.com.mac.elevator.states.Play.<init>(Play.java:91)
            at com.mac.elevator.handlers.GameStateManager.getState(GameStateManager.java:35)
            at com.mac.elevator.handlers.GameStateManager.pushState(GameStateManager.java:45)
            at com.mac.elevator.handlers.GameStateManager.<init>(GameStateManager.java:22)
            at com.mac.elevator.Game.create(Game.java:46)
            at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
            at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1521)
            at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)
Caused by: java.io.FileNotFoundException: res/level1.tmx
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:316)
at android.content.res.AssetManager.open(AssetManager.java:290)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75)
test this, copy the asset of your game, go to the folder of Android project, because that is how it works, LibGDX, is that the wiki LibGDX, talk about this but I do not remember where, try to put the file .tmx inside folder:
AndroidProyect -> asset -> maps -> yourmap.tmx.
and try to call it:
tileMap = new TmxMapLoader().load("maps/level1.tmx");
in your case, the, resources should go in the Asset Android project folder. While our code will be in the project completion "Core".

Categories

Resources