Android ADK 2011: IO Exception in run thread - android

I have an ADK Kit from Google I/O 2011 and I am trying to get the example application to work (Available here: http://developer.android.com/tools/adk/adk.html).
I have programmed the firmware and device as instructed, but cannot get the demo to work. The application starts, and detects the ADK board when plugged in, but then enters a loop in which the device connects then disconnects very rapidly, causing the UI Activity to keep restarting.
I have been debugging this for a few days, and have verified that the device gets an IOException in the run() method of DemoKitActivity.java which causes the thread to terminate, although I am unsure if this is caused by or the cause of the device disconnecting.
The exception thrown is:
06-27 23:21:51.284: E/DemoKit(13573): There was an IO Exception
06-27 23:21:51.284: E/DemoKit(13573): at libcore.io.IoBridge.read(IoBridge.java:435)
06-27 23:21:51.284: E/DemoKit(13573): at java.io.FileInputStream.read(FileInputStream.java:179)
06-27 23:21:51.284: E/DemoKit(13573): at java.io.InputStream.read(InputStream.java:163)
06-27 23:21:51.284: E/DemoKit(13573): at com.google.android.DemoKit.DemoKitActivity.run(DemoKitActivity.java:278)
06-27 23:21:51.284: E/DemoKit(13573): at java.lang.Thread.run(Thread.java:841)
06-27 23:21:51.284: E/DemoKit(13573): Caused by: libcore.io.ErrnoException: read failed: EIO (I/O error)
06-27 23:21:51.284: E/DemoKit(13573): at libcore.io.Posix.readBytes(Native Method)
06-27 23:21:51.284: E/DemoKit(13573): at libcore.io.Posix.read(Posix.java:127)
06-27 23:21:51.284: E/DemoKit(13573): at libcore.io.BlockGuardOs.read(BlockGuardOs.java:149)
06-27 23:21:51.284: E/DemoKit(13573): at libcore.io.IoBridge.read(IoBridge.java:425)
One possible quirk is that my device is set to communicate over PTP (Settings > Storage > Menu > USB Computer Connection > Camera (PTP).
I don't yet have much more information. I am hoping that someone can confirm that the example code provided by Google still works with the ADK, or can provide some insight into where to look next to debug the disconnections.

I can confirm that the example ADK code works with both a Nexus 4 running 4.2.1 and a Galaxy Nexus running 4.0.4.
I've tried both using the Gingerbread compatibility API and using the API 12 classes on the Android DemoKit app successfully.
The ADK 2011 board that I have hasn't been used recently so while it worked with a ICS (4.0.4) device it wasn't working with the Nexus 4 with JB.
The following SO topic covers the issue with JB:
ADK 1.0 devices fail to work with Jelly Bean, why?
Also the CapSense libraries have been renamed in the most recent download from the Arduino site. CapSense.h becomes CapacitorSensor.h and so on.
Otherwise I was able to install the new code onto the Arduino ADK board, install the app on the Android device and run the DemoKit app.
The Nexus 4 was also in PTP mode during my test so I don't that that is your problem.
I'm also assuming you got your logs via adb over wi-fi and not connecting it over usb as that cable should go into the ADK board. Other than making sure the ADK code is correct and perhaps trying it with a different USB cable or PC I don't have anything to suggest. While I did see some errors in the log for one test session, a reset of the ADK and app cleared it up. For reference here is my logcat from a working session hope it can help.
07-06 23:01:02.364 I/ActivityManager( 575): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.DemoKit/.DemoKitLaunch} from pid 899
07-06 23:01:02.404 I/ActivityManager( 575): Start proc com.google.android.DemoKit for activity com.google.android.DemoKit/.DemoKitLaunch: pid=8715 uid=10110 gids={50110, 1028}
07-06 23:01:02.495 I/DemoKitLaunch( 8715): starting phone ui
07-06 23:01:02.925 D/DemoKit ( 8715): accessory opened
07-06 23:01:03.185 I/ActivityManager( 575): Displayed com.google.android.DemoKit/.DemoKitPhone: +692ms (total +795ms)
07-06 23:01:35.690 D/UsbDeviceManager( 575): entering USB accessory mode: UsbAccessory[mManufacturer=Google, Inc., mModel=DemoKit, mDescription=DemoKit Arduino Board, mVersion=1.0, mUri=http://www.android.com, mSerial=0000000012345678]
07-06 23:01:35.690 I/ActivityManager( 575): START u0 {flg=0x10000000 cmp=com.android.systemui/.usb.UsbConfirmActivity (has extras)} from pid 575
07-06 23:01:35.860 I/ActivityManager( 575): Displayed com.android.systemui/.usb.UsbConfirmActivity: +64ms
07-06 23:01:37.782 I/ActivityManager( 575): START u0 {act=android.hardware.usb.action.USB_ACCESSORY_ATTACHED flg=0x10000000 cmp=com.google.android.DemoKit/.UsbAccessoryActivity (has extras)} from pid 748
07-06 23:01:37.912 I/DemoKitLaunch( 8715): starting phone ui
07-06 23:01:37.912 I/ActivityManager( 575): START u0 {flg=0x14000000 cmp=com.google.android.DemoKit/.DemoKitPhone} from pid 8715
07-06 23:01:38.022 D/DemoKit ( 8715): accessory opened

Related

Android App crashes when running on Windows 10 and VS2015 Android Emulator

Been trying to figure this out for a while but with no luck...
Background:
I am trying to run a Xamarin.Forms application within an Android Emulator through Visual Studio 2015 (update 3) on Windows 10. I installed all the required Android SDK and also ran against different emulators ranging from 4.4 Kitkat to 6.0 Marshmellow and I get the same results. The app is built with Xamarin.Forms with the pages in a portable C#/XAML project. #rd paty library FreshMVVM is used for IOC and ViewModels
Issue
The app mostly starts up first time but I typically have to wait 20-30 sec after deploy to run the app otherwise the app crashes straight away but the real issue is that when I get to the first page with a button on it (navigating to LoginPageModel), clicking the button will crash the app. The logcat Android Device Logging Window prints out the following during the crash... (sensitive info masked)
Things I have tried:
Removing constructor code from LoginPageModel class ... no change
Removing XAML. Mostly works but experience is inconsistant. Maybe related to the Xamarin forms controls?
Conrols used are: ContentPage, Image, ContentView, StackLayout, Entry, Label, Switch, Button
D/Mono ( 1585): Assembly Ref addref MyCompany[0xb7d43920] -> Xamarin.Insights[0xb7d3e690]: 3
I/MyCompany.REALAPI( 1585): Constructing ApiService.
I/MyCompany.LOGIN( 1585): AuthenticationRepositoryService is being constructed
I/MyCompany.LOGIN( 1585): Instantiating new LoginPageModel.
D/DonatelloNative_Selector( 134): Removing selector for fd 33
W/InputDispatcher( 464): channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
D/DonatelloNative_Selector( 134): Removing selector for fd 32
E/InputDispatcher( 464): channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 464): channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
E/InputDispatcher( 464): channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 464): Attempted to unregister already unregistered input channel 'a94e5108 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity (server)'
W/InputDispatcher( 464): Attempted to unregister already unregistered input channel 'a941cf20 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity (server)'
I/WindowState( 464): WIN DEATH: Window{a94e5108 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.SplashActivity}
I/ActivityManager( 464): Process com.mycompany.feature (pid 1585) has died.
W/ActivityManager( 464): Force removing ActivityRecord{a9308df8 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity t14}: app died, no saved state
I/WindowState( 464): WIN DEATH: Window{a941cf20 u0 com.mycompany.feature/md5bf4894c535574ee8d52747007a18ed49.MainActivity}
D/Zygote ( 139): Process 1585 terminated by signal (11)
W/EGL_emulation( 692): eglSurfaceAttrib not implemented
W/Binder ( 631): Caught a RuntimeException from the binder stub implementation.
W/Binder ( 631): java.lang.NullPointerException
W/Binder ( 631): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
W/Binder ( 631): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
W/Binder ( 631): at android.os.Binder.execTransact(Binder.java:404)
W/Binder ( 631): at dalvik.system.NativeStart.run(Native Method)
W/InputMethodManagerService( 464): Got RemoteException sending setActive(false) notification to pid 1585 uid 10054
Not sure if it is related to Hyper-V, the Emulator itself or the 3rd Party components.
Running the app as a Windows Universal app works fine.
Other machines running Windows 8.1 works fine also
Got this working though a change in the Hyper-V settings for the emulator.
Steps:
Open the Hyper-V Manager
Find the emulator under the list of Virtual Machines.
Right click the emulator entry and open it's settings.
As per image below, go to the Processor > Compatibility setting and ensure the "Migrate to a physcial computer with a different processor version" is checked

Prevent background service from being killed due to "detect excessive cpu on forked process"

I am debugging an issue of the Syncthing Android wrapper. The Android application wraps a native binary of the Syncthing project and provides some additional functionality like starting/stopping based on connecting WiFi, power, etc.
Unfortunately, there have been issues about the service not auto-starting on WiFi change anymore, especially with handsets that have been upgraded to Android 6. Since my personal handset has been upgraded to 6.0.1 recently, I finally am able to debug into the issue and today I noticed the following:
07-06 20:52:26.562 1181 1363 I ActivityManager: [BgDetect]chkExcessCpu doKills: true uptime: 300309
07-06 20:52:26.960 1181 1363 I ActivityManager: [BgDetect]detect excessive cpu on forked process libsyncthing.so(pid : 2758) plan to stop it 371060 during 300309
07-06 20:52:26.960 1181 1363 I ActivityManager: [BgDetect]force stop com.nutomic.syncthingandroid.debug (uid 10132)
07-06 20:52:26.965 1181 1363 I ActivityManager: Force stopping com.nutomic.syncthingandroid.debug appid=10132 user=0: from pid 1181
07-06 20:52:26.966 1181 1363 I ActivityManager: Killing 1360:com.nutomic.syncthingandroid.debug/u0a132 (adj 15): stop com.nutomic.syncthingandroid.debug
07-06 20:52:26.968 1181 1363 W ActivityManager: Scheduling restart of crashed service com.nutomic.syncthingandroid.debug/com.nutomic.syncthingandroid.syncthing.SyncthingService in 1000ms
07-06 20:52:26.968 1181 1354 V ActivityManager: killProcessGroupAsync took 1 ms for PID 1360 on thread 14
07-06 20:52:26.971 1181 6410 I libprocessgroup: Killing pid 2758 in uid 10132 as part of process group 1360
07-06 20:52:26.973 1181 6410 I libprocessgroup: Killing pid 2758 in uid 10132 as part of process group 1360
07-06 20:52:26.974 1181 1363 I ActivityManager: Force stopping service ServiceRecord{47304c8 u0 com.nutomic.syncthingandroid.debug/com.nutomic.syncthingandroid.syncthing.SyncthingService}
The Syncthing protocol is quite heavy on the CPU side, regarding encryption, hashing, etc. So it seems that the service is force-stopped due to the high CPU demands of the forked native binary.
The application is already marked as "No battery optimization", but still it is being killed. Is there a way to prevent the ActivityManager from killing the application due to the CPU demands of the forked process?
Unfortunately, this is a OnePlus / OxygenOS feature that will kill any background process based on who-knows what rules in order to give the appearance of a better battery life.
For now, I found a non-code workaround in a GitHub issue that seems to help, but is far from ideal: pin/lock the application on the recents screen.
Was testing my foreground service and realized it was a performance issue mainly CPU. So I enforced performance with the profiler and added to the white list.
Reduced the consumption cpu, ram and battery and its done.
Foreground notification service not working in one plus devices

Swipe app out of recent tasks in Android 6.0 but not kill the app process?

The app(pkg:com.demo.app) service is foreground.
Before Android 6.0, when I swipe an app out of the recent tasks, the display log is:
04-11 19:44:34.337 1003-2301/? D/ActivityManager: for debug: forceStopPackage[pkg:com.demo.app,userId:0], caller[pid:23919,uid:1000]
04-11 19:44:34.337 1003-2301/? I/ActivityManager: Force stopping com.demo.app appid=10238 user=0: from pid 23919
04-11 19:44:34.337 1003-2301/? I/ActivityManager: Killing 11059:com.demo.app/u0a238 (adj 2): stop com.demo.app
In Android 6.0, it is not. The app process is still alive.
How to explain this?

SEandroid Boot Up Problems

I'm currently working on flashing SEandroid (security enhanced Android) onto a Nexus 7, but when I try to boot up, the Nexus 7 just flashes the Google screen and nothing else.
I successfully compiled the SEandroid Source code for both 4.2.1 and 4.1.2 and neither run on the Nexus.
Was wondering what some common errors could be for a device booting up, but the screen not showing anything?
I downloaded and compiled the code according to: http://selinuxproject.org/page/SEAndroid
I am using the tegra3_android_defconfig for my kernel and am using the full_grouper_userdebug.
Any help, even if not related to SEandroid would be helpful.
Here is an output from logcat:
--------- beginning of /dev/log/main
I/Netd ( 124): Netd 1.0 starting
W/InterfaceController( 124): Warning (Cannot load library: load_library(linker.cpp:745): library "/system/lib/libnetcmdiface.so" not found) while opening the net interface command library
I/installd( 130): installd firing up
I/DEBUG ( 125): debuggerd: Jun 12 2013 10:32:23
I/SurfaceFlinger( 126): SurfaceFlinger is starting
I/SurfaceFlinger( 126): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
E/libEGL ( 126): eglGetDisplay:121 error 300c (EGL_BAD_PARAMETER)
E/libEGL ( 126): eglInitialize:137 error 3008 (EGL_BAD_DISPLAY)
Thanks in advanced.
Rookie mistake. Forgot to add in Google's proprietary drivers for the Nexus 7.
Available here for who ever needs them!
https://developers.google.com/android/nexus/drivers
thanks all

Android Eclipse failing to debug

Debugging of my app is now suddenly broken. It has been fine up to now and I even reloaded a known good version of my entire code and it still fails to debug or even run. When I hit debug or run the app starts up and right when it is about to display the app, it crashes (before even entering the main view). I have a break point on the first line of code and it never even reaches it. It just goes to Source not found - The source attachment does not contains the source for the file DexFile.class.....
I am 100% certain all the code I have loaded is working, as it is a saved backup which was saved when last working.
Also, what is odd is that if I unplug the cable at this point, the app loads normally and works fine. So this is definitely a debugging issue. It is getting stuck somewhere at boot. I have restarted my computer and phone several times to no avail.
LogCat:
`04-04 11:17:33.462: DEBUG/AndroidRuntime(4148): CheckJNI is OFF
04-04 11:17:33.462: DEBUG/dalvikvm(4148): creating instr width table
04-04 11:17:33.502: DEBUG/AndroidRuntime(4148): --- registering native functions ---
04-04 11:17:33.712: DEBUG/AndroidRuntime(4148): Shutting down VM
04-04 11:17:33.712: DEBUG/dalvikvm(4148): Debugger has detached; object registry had 1 entries
04-04 11:17:33.712: INFO/AndroidRuntime(4148): NOTE: attach of thread 'Binder Thread #3' failed
04-04 11:17:33.902: DEBUG/AndroidRuntime(4157): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
04-04 11:17:33.902: DEBUG/AndroidRuntime(4157): CheckJNI is OFF
04-04 11:17:33.902: DEBUG/dalvikvm(4157): creating instr width table
04-04 11:17:33.942: DEBUG/AndroidRuntime(4157): --- registering native functions ---
04-04 11:17:34.152: INFO/Process(107): Sending signal. PID: 4137 SIG: 9
04-04 11:17:34.152: INFO/ActivityManager(107): Force stopping package org.scanner uid=10110
04-04 11:17:34.162: ERROR/ActivityManager(107): fail to set top app changed!
04-04 11:17:34.182: INFO/UsageStats(107): Unexpected resume of com.htc.launcher while already resumed in org.scanner
04-04 11:17:34.192: INFO/ActivityManager(107): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.obdscanner/.activity.ObdReaderMainActivity }
04-04 11:17:34.202: DEBUG/AndroidRuntime(4157): Shutting down VM
04-04 11:17:34.202: DEBUG/dalvikvm(4157): Debugger has detached; object registry had 1 entries
04-04 11:17:34.212: INFO/AndroidRuntime(4157): NOTE: attach of thread 'Binder Thread #3' failed
04-04 11:17:34.222: WARN/InputManagerService(107): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#464105d8
04-04 11:17:34.242: INFO/ActivityManager(107): Start proc org.scanner for activity org.obdscanner/.activity.ReaderMainActivity: pid=4165 uid=10110 gids={3003, 3002}
04-04 11:17:34.332: WARN/ActivityThread(4165): Application org.scanner is waiting for the debugger on port 8100...
04-04 11:17:34.332: INFO/System.out(4165): Sending WAIT chunk
04-04 11:17:34.352: INFO/dalvikvm(4165): Debugger is active
04-04 11:17:34.472: DEBUG/Norton Community Watch/smrsd(3910): smrsd broadcast intent success!
04-04 11:17:34.512: ERROR/(3910): /data/data/com.symantec.monitor/app_log_item/1301930254.txt//data/data/com.symantec.monitor/app_log_item
04-04 11:17:34.542: INFO/System.out(4165): Debugger has connected
04-04 11:17:34.542: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:34.632: INFO/global(3898): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
04-04 11:17:34.742: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:34.862: DEBUG/dalvikvm(3898): GC_FOR_MALLOC freed 4492 objects / 274560 bytes in 41ms
04-04 11:17:34.942: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.142: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.342: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.552: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.752: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:35.952: INFO/System.out(4165): waiting for debugger to settle...
04-04 11:17:36.157: INFO/System.out(4165): debugger has settled (1451)
04-04 11:17:37.296: DEBUG/dalvikvm(4165): threadid=1: still suspended after undo (sc=1 dc=1 s=Y)
`
Please see the correct annswer HERE
You have set a break point in one of the classes. Just take off all the break points in your project and run again, their will be no problem.
Eclipse->Window->Show View->(Other->Debug->)Breakpoints
Occasionally Eclipse and the various Android development plug-ins will become out of sync. I usually attempt the following when debugging / development gets "funky"
If your Logcat is not displaying lines, clear it. It has a small buffer. Also ensure that your device is selected in the "DDMS" perspective. If you have the emulator selected you will only receive logging from it.
Clean and Rebuild all open projects. Ensure there are no errors.
Uninstall the application from the remote device/emulator.
Restart Eclipse!
Open a terminal on your platform and use the tool adb in the "platform-tools" directory.
adb kill-server
adb start-server
Stash your working copy and revert your source code if using a repository.
Strange solution...I just closed the project from package explorer, then removed it from the workspace. Closed Eclipse. Re-opened Eclipse and imported the project.
(Copy and pasted from Jesse's comment.)
I tried all of the above, but i turned out that it was not working due to multiple instances of eclipse.exe
Killing them all in the task manager (CTRL+SHIFT+ESC) solved it.
On your Android device (or emulator) go to:
Applications - Settings - Applications - Manage applications - All
There you have to select your app and uninstall it.
Afterwards try to run your app from the IDE again. It should work now.
Create a new debug configuration of type Remote Java Application and set it to localhost and the port you see on the DDMS window.
https://stackoverflow.com/a/13421917/624109
I know this is kind of late.... use it if #Sam's or #Killesk's answers do not work.
ensure the manifest sets android:debuggable.
In onCreate, add a call to Debug.waitForDebugger.
Adding the call to waitForDebugger also works when reversing. For example you can add the following by hand in onCreate and have smali/baksmali recompile it:
invoke-static {}, Landroid/os/Debug;->waitForDebugger()V
I don't have to use the tricks often, but when I do, waitForDebugger always works. I don't recall a time I could not snap the debugger with it.
I've had this happen due to my code being obfuscated. I didn't notice that someone had changed proguard.cfg for a production release and commented-out the "-dontobfuscate" line.

Categories

Resources