I am trying to connect a USB Camera with an OTG cable on my Android app and for this purpose I use the UVCCamera repo. All the samples and my app work fine on most devices I have tested, but not on a Motorola E4 (on which I specifically need to run the app).
What I have noticed is that the UsbDevice is detached right after I grant permission to use it, and then is reattached as a new device. If I don't check if this happens I get a NullPointerException as the connection to the device is null when trying to get raw descriptors.
Here are the error messages I get:
E/UsbManager: exception in UsbManager.openDevice
java.lang.IllegalArgumentException: device /dev/bus/usb/001/008 does not exist or is restricted
at android.os.Parcel.readException(Parcel.java:1688)
at android.os.Parcel.readException(Parcel.java:1637)
at android.hardware.usb.IUsbManager$Stub$Proxy.openDevice(IUsbManager.java:443)
at android.hardware.usb.UsbManager.openDevice(UsbManager.java:353)
at com.serenegiant.usb.USBMonitor$UsbControlBlock.<init>(USBMonitor.java:1011)
at com.serenegiant.usb.USBMonitor$UsbControlBlock.clone(USBMonitor.java:1034)
at com.serenegiant.usb.UVCCamera.open(UVCCamera.java:192)
at com.serenegiant.usbcameracommon.AbstractUVCCameraHandler$CameraThread.handleOpen(AbstractUVCCameraHandler.java:444)
at com.serenegiant.usbcameracommon.AbstractUVCCameraHandler.handleMessage(AbstractUVCCameraHandler.java:300)
at com.serenegiant.usbcameracommon.UVCCameraHandler.handleMessage(UVCCameraHandler.java:31)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at com.serenegiant.usbcameracommon.AbstractUVCCameraHandler$CameraThread.run(AbstractUVCCameraHandler.java:747)
12-07 16:08:36.074 20866-20883/com.serenegiant.usbcameratest E/AndroidRuntime: FATAL EXCEPTION: USBMonitor Process: com.serenegiant.usbcameratest, PID: 20866 java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] android.hardware.usb.UsbDeviceConnection.getRawDescriptors()' on a null object reference
at com.serenegiant.usb.USBMonitor.updateDeviceInfo(USBMonitor.java:900)
at com.serenegiant.usb.USBMonitor$UsbControlBlock.<init>(USBMonitor.java:974)
t com.serenegiant.usb.USBMonitor$UsbControlBlock.<init>(USBMonitor.java:0)
at com.serenegiant.usb.USBMonitor$3.run(USBMonitor.java:563)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Other applications on Google Play that use the same library to connect USB cameras work fine on the Motorola E4 too.
I have also posted the issue on github some time ago but have not got any answers.
Related
I have launched an app on play store but it is crashing on several devices & I am not able test my app on every devices. i have crashlytics report
Crashlytics Report
Stack Trace
Fatal Exception: java.lang.RuntimeException: Internal error in Cloud Firestore (23.0.1).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:19)
at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$jx84dqgUsF4ojecSMurRqFLFD1Y.run(-.java:2)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962)
Caused by java.lang.RuntimeException: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java:14)
at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$SynchronizedShutdownAwareExecutor$pKSAgg-ozJ8RbUveSl-44aUfFQw.run(-.java:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:15)
at java.lang.Thread.run(Thread.java:764)
Caused by android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY)
at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:578)
at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:553)
at android.database.sqlite.SQLiteDatabase.beginTransactionWithListener(SQLiteDatabase.java:517)
at com.google.firebase.firestore.local.SQLitePersistence.runTransaction(SQLitePersistence.java:17)
at com.google.firebase.firestore.local.LocalStore.startMutationQueue(LocalStore.java:9)
at com.google.firebase.firestore.local.LocalStore.start(LocalStore.java)
at com.google.firebase.firestore.core.ComponentProvider.initialize(ComponentProvider.java:41)
at com.google.firebase.firestore.core.FirestoreClient.initialize(FirestoreClient.java:65)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0(FirestoreClient.java:10)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$0$FirestoreClient(FirestoreClient.java)
at com.google.firebase.firestore.core.-$$Lambda$FirestoreClient$Eq-cAcb1C1mM4tyiJsLJXZ13tyU.run(-.java:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$2(AsyncQueue.java)
at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$Y9GO7zO2DX6MzQJ5TbKtKW_NzO0.call(-.java:2)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor.lambda$executeAndReportResult$1(AsyncQueue.java)
at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$SynchronizedShutdownAwareExecutor$pKSAgg-ozJ8RbUveSl-44aUfFQw.run(-.java:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:15)
at java.lang.Thread.run(Thread.java:764)
Device Information
Brand:OPPO
Model:
Orientation: Portrait
RAM free: 3.28 GB
Disk free: 95.39 GB
Date: 26-07-2021
Operating System
Version:9
Orientation: Portrait
Rooted:No
Other devices with same issue
Oppo: F17 Pro,CPH1853
Realme: 5i,c12,8pro
vivo: 1920,1803
My take on this is that an sqlite query is being executed on an sqlite connection that is already processing a query based on the fact that it is executing side a threaded background worker. it is possible that the system sqlite on this system may be compiled differently such as being in single threaded mode
the cause of this looks to be the firebase library and how it operates and if this is a systems issue (android on the oppo and the provided sqlite) then you may have to detect how it was compiled or bundle a verison of sqlite to work around this
it should be possible to dump the compile options of sqlite via an sql conenction and compare this to a knwn
So I've added the firebase messaging library to gradle, and when i am on my Firebase console and send a notification to devices, It completely crashes my System UI of the device, freezing the phone and making it do weird things. The System UI also crashes without notifications, seeming to be only happening after ive added the gradle dependency for cloudmessaging.
The only indication i have is this error
rocess: com.android.systemui, PID: 18646
java.lang.OutOfMemoryError: Failed to allocate a 64000012 byte allocation with 4193696 free bytes and 51MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:651)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:486)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1085)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2867)
at android.content.res.Resources.loadDrawable(Resources.java:2756)
at android.content.res.Resources.getDrawable(Resources.java:920)
at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:313)
at android.graphics.drawable.Icon.loadDrawable(Icon.java:269)
at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:377)
at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:199)
at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:184)
at com.android.systemui.statusbar.StatusBarIconView.updateDrawable(StatusBarIconView.java:171)
at com.android.systemui.statusbar.StatusBarIconView.set(StatusBarIconView.java:137)
at com.android.systemui.statusbar.BaseStatusBar.createIcon(BaseStatusBar.java:1860)
at com.android.systemui.statusbar.BaseStatusBar.createNotificationViews(BaseStatusBar.java:1826)
at com.android.systemui.statusbar.phone.PhoneStatusBar.addNotification(PhoneStatusBar.java:1429)
at com.android.systemui.statusbar.BaseStatusBar$6$2.run(BaseStatusBar.java:548)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Recently started getting crashes due to java.lang.SecurityException: Binder invocation to an incorrect interface in our app which only happens on 6.0 and 6.0.1 OS.
The stack trace is pulled from a crash reporting service and could not be replicated locally on any of the Android 6 devices.
The app uses a 'Service' which calls 'startForeground' and the stack trace seems to point to that method call.
java.lang.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.setServiceForeground(ActivityManagerNative.java:4487)
at android.app.Service.startForeground(Service.java:652)
at com.anghami.audio.MusicService.J(MusicService.java:3517)
at com.anghami.audio.MusicService.b(MusicService.java:2676)
at com.anghami.audio.MusicService.F(MusicService.java:2647)
at com.anghami.audio.MusicService.a(MusicService.java:2421)
at com.anghami.audio.MusicService_.a(MusicService_.java:21)
at com.anghami.audio.MusicService_$4.a(MusicService_.java:214)
at org.androidannotations.api.a$a.run(BackgroundExecutor.java:401)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
The problem occurred when .Aidl file in client side were placed in wrong location.
the .Aidl file must be placed in a package of the same name as server side in the client's src folder.
I'm using this tutorial to make an Android login application. I have followed all his steps and successfully am able to load the application on the emulator or my phone, however when I try and create an account I get an error - I followed the instructions he provided stating how to test the system, referencing to here:
Testing the App
For a beginner it will be always difficult to run this project for the first time. But don’t worry, the following steps will helps you testing this app. (The ip address looks like 192.168.0.100)
Make sure that both devices (the device running the PHP project and the android device) are on the same wifi network.
Give correct username , password and database name of MySQL in Config.php
Replace the URL ip address of URL_LOGIN and URL_REGISTER in AppConfig.java with your machine ip address. You can get the ip address by running ipconfig in cmd
my IPv4 address is 192.168.0.11,
So I added that to the AppConfig file as follows:
package android.loginfirstattempt.com.loginfirstattempt.app;
public class AppConfig {
// Server user login url
public static String URL_LOGIN = "http://192.168.0.11/android_login_api/login.php";
// Server user register url
public static String URL_REGISTER = "http://192.168.0.11/android_login_api/register.php";
}
I am using Android Studio's built in emulator so both devices are on the same network.
I am using Lampp and I'm under the assumption by default this is the username and password:
<?php
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("DB_DATABASE", "android_api");
?>
I started the local servers and tested to make sure they were running by loading up a demo page.
I've already also created the MySQL database and table as shown in his example.
My file structure for the server side is shown in this picture
But when I try create a User I get this crash:
beginning of crash
06-26 19:12:13.205 2668-2668/android.loginfirstattempt.com.loginfirstattempt E/AndroidRuntime: FATAL EXCEPTION: main
Process: android.loginfirstattempt.com.loginfirstattempt, PID: 2668
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.loginfirstattempt.com.loginfirstattempt.app.AppController.addToRequestQueue(com.android.volley.Request, java.lang.String)' on a null object reference
at android.loginfirstattempt.com.loginfirstattempt.activity.RegisterActivity.registerUser(RegisterActivity.java:189)
at android.loginfirstattempt.com.loginfirstattempt.activity.RegisterActivity.access$300(RegisterActivity.java:35)
at android.loginfirstattempt.com.loginfirstattempt.activity.RegisterActivity$1.onClick(RegisterActivity.java:84)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I am unable to find any obvious error and was wondering if someone could help!
You didn't add the AppController to the application tag in the AndroidManifest.xml as explained in the tutorial. Your AppController now doesn't get called during the initialization of your app and isn't initialized. When you call AppController.getInstance().addToRequestQueue(strReq, tag_string_req); inside your registerUser method AppController.getInstance() returns null. This causes your nullpointerException. Add the AppController to the manifest and your code should be working.
Your application tag should look like this:
<application
android:name="com.loginfirstattempt.app.AppController"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
I am new to android development, and have run into a problem I seem unable to solve.
My android app should be able to communicate with my arduino device, sending info
to and retrieving info from my device. I have set up my connection between the two
with a bluetooth device and I am using amarino to facilitate the communication.
Now I can connect with amarino and send data and receive data, now I want to do this from
my app. The problem comes when I enter this line:
private static final String DEVICE_ADDRESS = "07:12:04:16:68:18";
Amarino.connect(this, DEVICE_ADDRESS);
The number is the MAC address of my bluetooth adapter connected to my arduino device.
As soon as I run my app on my phone it just force closes due to unexpected error.
Now as I said, I am a bit of a noob when it comes to android, so I installed logCat to try get some log info out of it. All I got from it was this somewhat unhelpful error message:
com.example.projectgreetv3/.StartingPlace
10-24 15:22:55.140 E/AndroidRuntime(4906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projectgreetv3/com.example.projectgreetv3.StartingPlace}: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk]
10-24 15:22:55.140 E/AndroidRuntime(4906): Caused by: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk]
10-24 15:22:55.148 W/ActivityManager(539): Force finishing activity com.example.projectgreetv3/.StartingPlace
10-24 15:21:51.726 I/UinboxLogger(4585): [UinboxReceiver] onReceive() >> intent.getData() : com.example.projectgreetv3
10-24 15:21:52.382 I/UninstallAppProgress(4575): Finished uninstalling pkg: com.example.projectgreetv3
10-24 15:22:52.523 D/PackageManager(539): Scanning package com.example.projectgreetv3
I hope someone can help me with this, as I am on wits end.
For more info on:
- Arduino:
- http://www.arduino.cc/
- Amarino:
http://www.amarino-toolkit.net/
If you look a bit further down on your stacktrace (in the logcat) you will probably see that the cause of this crash is an NetworkOnMainThreadException. (If you are running Android 3.0 or higher)
Please make sure that you do all your network communication on a separate thread (Thread/ASyncTask).
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html