When I copy file on android 31 throw IllegalStateException - java

I need to rerecord video and copy to my Private Storage but when I copy file throw IllegalStateException
What is the solution here?
This video shows how the crash occurs
E/AndroidRuntime: FATAL EXCEPTION: pool-25-thread-1
Process: com.majd.paraibachat, PID: 13789
java.lang.IllegalStateException: Only owner is able to interact with pending item content://media/external_primary/video/media/150
at android.os.Parcel.createExceptionOrNull(Parcel.java:2433)
at android.os.Parcel.createException(Parcel.java:2409)
at android.os.Parcel.readException(Parcel.java:2392)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:780)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1518)
at com.majd.paraibachat.persistance.FileBackend.copyFileToPrivateStorage(FileBackend.java:716)
at com.majd.paraibachat.persistance.FileBackend.copyFileToPrivateStorage(FileBackend.java:917)
at com.majd.paraibachat.services.AttachFileToConversationRunnable.processAsFile(AttachFileToConversationRunnable.java:71)
at com.majd.paraibachat.services.AttachFileToConversationRunnable.run(AttachFileToConversationRunnable.java:176)
at com.majd.paraibachat.utils.SerialSingleThreadExecutor$Runner.run(SerialSingleThreadExecutor.java:60)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)

Related

Cannot capture image in the second time - Android

im using kevalpatel2106's android hidden camera library.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.exampleapp, PID: 10608
java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1865)
at android.hardware.Camera.takePicture(Camera.java:1806)
at com.androidhiddencamera.CameraPreview.takePictureInternal(CameraPreview.java:196)
at com.androidhiddencamera.HiddenCameraActivity.takePicture(HiddenCameraActivity.java:92)
at com.example.exampleapp.MainActivity.lambda$onCreate$3$MainActivity(MainActivity.java:152)
at com.example.exampleapp.MainActivity$$ExternalSyntheticLambda4.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7888)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
when the application instance taking picture the first time it works fine, but in the second time it throws me this error.
I'm using LGE LM-K520 device android 11.
this is the code:
findViewById(R.id.pic).setOnClickListener((a) -> takePicture());
this is my config:
mCameraConfig = new CameraConfig()
.getBuilder(MainActivity.this)
.setCameraFacing(CameraFacing.REAR_FACING_CAMERA)
.setCameraResolution(CameraResolution.HIGH_RESOLUTION)
.setImageFormat(CameraImageFormat.FORMAT_JPEG)
.setImageRotation(CameraRotation.ROTATION_90)
.build();
Thank You!!!

Exoplayer video support crashing the app in release build

This crash occurs in playing the mp4 stream. Exoplayer version 12.2.0 . Android Run in debug mode - everything is fine. Run in release mode - app crashes
Fatal Exception: java.lang.AbstractMethodError: abstract method "java.lang.Object com.google.a.a.c.a(java.lang.Object)"
--------- beginning of crash
2021-02-10 12:52:49.385 4549-4645/? E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Playback
Process: app.baff, PID: 4549
java.lang.AbstractMethodError: abstract method "void com.google.android.exoplr2avp.extractor.TrackOutput.sampleData(com.google.android.exoplr2avp.util.ParsableByteArray, int)"
at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:536)
at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:200)
at com.google.android.exoplr2avp.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127)
at com.google.android.exoplr2avp.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1046)
at com.google.android.exoplr2avp.upstream.Loader$LoadTask.run(Loader.java:415)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
2021-02-10 12:52:49.385 4549-4649/? E/AndroidRuntime: FATAL EXCEPTION: Loader:ProgressiveMediaPeriod
Process: app.baff, PID: 4549
java.lang.AbstractMethodError: abstract method "void com.google.android.exoplr2avp.extractor.TrackOutput.sampleData(com.google.android.exoplr2avp.util.ParsableByteArray, int)"
at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:536)
at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:200)
at com.google.android.exoplr2avp.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127)
at com.google.android.exoplr2avp.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1046)
at com.google.android.exoplr2avp.upstream.Loader$LoadTask.run(Loader.java:415)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Add this line in the proguard config file fixes the issue for me.
-keepnames class com.google.common.** { *; }
Visit
google/guava#322 for more resources.
https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/580
android.enableDexingArtifactTransform=false
-keepnames class com.google.common.** { *; }

Android Studio Weather Application Crashing

So, I have been following a YouTube tutorial for an android Weather application. The app seems to compile, however crashes whenever opened on the emulator. I'm not the most fluent programmer, however the code is understood. I can't figure out what's causing the issue though. The app is supposed to fetch weather data for the location of the hardcoded location in "MainActivity.java". The data is fetched from Yahoo! using an API.
Link for the project files: https://drive.google.com/drive/folders/0B2dQ9-JQjysVeXlqZENBZDExN0E?usp=sharing
Below is the error I get:
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mattbenson.cw_2_weather, PID: 2529
java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at com.example.mattbenson.cw_2_weather.service.WeatherService$1.onPostExecute(WeatherService.java:81)
at com.example.mattbenson.cw_2_weather.service.WeatherService$1.onPostExecute(WeatherService.java:38)
at android.os.AsyncTask.finish(AsyncTask.java:667)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
E/EGL_emulation: tid 2570: swapBuffers(487): error 0x300d (EGL_BAD_SURFACE)
W/OpenGLRenderer: swapBuffers encountered EGL error 12301 on 0x76990bb1c580, halting rendering...
Application terminated.
(Sorry, I am new to this site!)
Any help is greatly appreciated.
As StackTrace says the error is at Class WeatherService at line 81 int count = queryResults.optInt("Count"); because it is returning NULL.
Try using method optInt with fallback value queryResults.optInt("Count", 0);

Android Studio Loading Texture error

I have this strange error where I can't load any textures anymore. The assets that I used are fine, but when I try to add new assets, it throws me this:
E/AndroidRuntime: FATAL EXCEPTION: GLThread 9855
Process: com.NeverMind.MainClass.android, PID: 18482
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bg.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.NeverMind.DontFall.android.MainClass.create(MainClass.java:200)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1520)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
Caused by: java.io.IOException: Error loading pixmap: decoder init failed for stream
at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>(Gdx2DPixmap.java:57)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:138)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98) 
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100) 
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92) 
at com.NeverMind.DontFall.android.MainClass.create(MainClass.java:200) 
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1520) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248) 
I didn't do anything stupid. I also tried to trick him and put the new texture with the name of an old one and it didn't work. This is the first time this happens, I have thousands of lines in the code.
The problem was with the bit depth. It needs to be smaller.

getResources returns null

We register a broadcast receiver to receive package installment or uninstallment event.
But some users report crash reports like this:
java.lang.RuntimeException: Unable to create application com.kc.security.MoSecurityApplication: java.lang.RuntimeException: getResources is null: dir - /data/app/com.cm.mg-1.apk, srcVal-1, srcVal-2
at android.app.LoadedApk.makeApplication(LoadedApk.java:495)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2249)
at android.app.ActivityThread.access$1600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: getResources is null: dir - /data/app/com.cm.mg-1.apk, srcVal-1, srcVal-2
at com.kc.security.b.ab.b(UpdateManager.java:69)
at com.kc.security.b.ab.a(UpdateManager.java:112)
at com.kc.security.MoSecurityApplication.onCreate(MoSecurityApplication.java:66)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.LoadedApk.makeApplication(LoadedApk.java:492)
... 11 more
It is not easy to reappear this crash. We think a lot about this problem. We receive a
uninstall event ,then the Application context Class called it's onCreate method, we do
some initial works there , when we call getResouce(), it returns null . When look deep
inside the framework codes, we find that getReource locate resources file by sourceDir
String in ApplicationInfo, and the String is "/data/app/com.cm.mg-1.apk" > it's the original apk , and it is not exists anymore.
It maybe happens when user update our application. In some way "/data/app/com.cm.mg-1.apk" is allready deleted and replace by "/data/app/com.cm.mg-2.apk" any way, but the "sourceDir" String in ApplicationInfo is not update.
I want to know what android does when doing a updating.
Encountered a similar problem, check this out.
RuntimeException: Unable to instantiate application
I think this should answer this question, maybe because the Resources has been destroyed during this uninstall event.

Categories