Android Things - I2C2 is already in use (code 16) - gpio

I am trying to connect ADS1015 ADC with my Pico Pro Maker. Unfortunately, I got folowing error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cililing.harvbox.thingsapp, PID: 1855
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:448)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Caused by: com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I2C2 is already in use (code 16)
at com.google.android.things.pio.I2cDeviceImpl.<init>(I2cDeviceImpl.java:43)
at com.google.android.things.pio.PeripheralManager.openI2cDevice(PeripheralManager.java:246)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:200)
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:187)
at com.cililing.harvbox.thingsapp.thingscontroller.controllers.ADS1015ControllerImpl.<init>(ADS1015Controller.kt:12)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:40)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:33)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.cililing.harvbox.thingsapp.ui.MainActivity.getI2CController(Unknown Source:25)
at com.cililing.harvbox.thingsapp.ui.MainActivity.access$getI2CController$p(MainActivity.kt:33)
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2cLogger$1.run(MainActivity.kt:47)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Caused by: android.os.ServiceSpecificException: I2C2 is already in use (code 16)
at android.os.Parcel.readException(Parcel.java:2027)
at android.os.Parcel.readException(Parcel.java:1959)
at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.OpenI2cDevice(IPeripheralManagerClient.java:1243)
at com.google.android.things.pio.I2cDeviceImpl.<init>(I2cDeviceImpl.java:41)
at com.google.android.things.pio.PeripheralManager.openI2cDevice(PeripheralManager.java:246) 
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:200) 
at com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx.<init>(Ads1xxx.java:187) 
at com.cililing.harvbox.thingsapp.thingscontroller.controllers.ADS1015ControllerImpl.<init>(ADS1015Controller.kt:12) 
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:40) 
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2CController$2.invoke(MainActivity.kt:33) 
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) 
at com.cililing.harvbox.thingsapp.ui.MainActivity.getI2CController(Unknown Source:25) 
at com.cililing.harvbox.thingsapp.ui.MainActivity.access$getI2CController$p(MainActivity.kt:33) 
at com.cililing.harvbox.thingsapp.ui.MainActivity$i2cLogger$1.run(MainActivity.kt:47) 
at android.os.Handler.handleCallback(Handler.java:790) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
I am using following driver:
https://github.com/androidthings/contrib-drivers/tree/master/adc
What I've already done:
uninstall all apps
reinstall whole AndroidThings
I tired both, I2C1 and I2C2
try to read value on new app (only example from library).
I have no idea what can I do more. I am pretty sure that device is connected properly (scl-scl, sda-sda, addr-gnd, a0-other_analog_output) to main board and error is actually kind of strange, as I am sure that none other app uses those pins.
code responsible for connecting with peripheral:
class ADS1015ControllerImpl(val i2cName: String,
val range: Int) : ADS1015Controller {
private val instance: Ads1xxx = Ads1xxx(i2cName, Ads1xxx.Configuration.ADS1015)
init {
instance.inputRange = range
}
override fun read(channel: Int, logger: (Int) -> Unit) {
logger.invoke(
instance.readSingleEndedInput(channel)
)
}
override fun release() {
instance.close()
}
}

The error message I2C2 is already in use (code 16) means you are trying to open more than one connection to the same I2C bus without closing the previous instance. The code to open the I2C connection lives within the Ads1xxx constructor. You must either manage a single instance of this class in your code, or be certain that you call close() on the current Ads1xxx before initializing another one.
Based on the stack trace, it also looks like this device is being initialized by a lazy load when the value it first accessed, so it's possible that this constructor is not getting invoked at the point you expected, causing things to come out of order.

In fact, the problem was a badly soldered plug. :)

Related

IDE Fatal Erors

My Android Studio gives me this fatal error.
So Far, I did ivalidated cache, I restored to default settings, I even configured VM acceleration but nothing worked.
I also getting syntax highlighting has been temporarily turned off because of an internal error in my mainActivity.kt, and it doesn't show any preview despite the #Preview tag.
The stacktrace is as follows:
java.lang.NullPointerException
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenComponentFactory.lambda$createEventLink$1(WelcomeScreenComponentFactory.java:303)
at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:417)
at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:390)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:372)
at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:33)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:179)
at com.sun.proxy.$Proxy96.notificationsChanged(Unknown Source)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl.updatePopup(WelcomeBalloonLayoutImpl.java:181)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl$3.dispose(WelcomeBalloonLayoutImpl.java:124)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.ui.BalloonLayoutImpl.dispose(BalloonLayoutImpl.java:84)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl.dispose(WelcomeBalloonLayoutImpl.java:51)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame.dispose(FlatWelcomeFrame.java:232)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:139)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:169)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205)
at com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame$1.projectOpened(FlatWelcomeFrame.java:124)
at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
at com.intellij.util.messages.impl.MessageBusImpl.access$300(MessageBusImpl.java:33)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.executeOrAddToQueue(MessageBusImpl.java:208)
at com.intellij.util.messages.impl.CompositeMessageBus$ToDirectChildrenMessagePublisher.publish(CompositeMessageBus.java:105)
at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:166)
at com.sun.proxy.$Proxy128.projectOpened(Unknown Source)
at com.intellij.openapi.project.impl.ProjectManagerExImplKt$openProject$1.run(ProjectManagerExImpl.kt:468)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:951)
at com.intellij.openapi.progress.util.ProgressWindow.lambda$startBlocking$6(ProgressWindow.java:221)
at com.intellij.openapi.application.impl.ApplicationImpl.runUnlockingIntendedWrite(ApplicationImpl.java:831)
at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:217)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$execFromEDT$6(ProgressRunner.java:321)
at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:753)
at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2108)
at com.intellij.openapi.progress.impl.ProgressRunner.execFromEDT(ProgressRunner.java:318)
at com.intellij.openapi.progress.impl.ProgressRunner.submit(ProgressRunner.java:259)
at com.intellij.openapi.progress.impl.ProgressRunner.submitAndGet(ProgressRunner.java:185)
at com.intellij.openapi.project.impl.ProjectUiFrameAllocator.run(ProjectFrameAllocator.kt:116)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.doOpenAsync(ProjectManagerExImpl.kt:119)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProjectAsync(ProjectManagerExImpl.kt:110)
at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProject(ProjectManagerExImpl.kt:72)
at com.intellij.ide.impl.ProjectUtil.tryOpenOrImport(ProjectUtil.java:172)
at com.intellij.ide.impl.ProjectUtil.openOrImport(ProjectUtil.java:131)
at com.intellij.ide.impl.ProjectUtil.openOrImport(ProjectUtil.java:127)
at com.android.tools.idea.actions.AndroidOpenFileAction.openOrImportProject(AndroidOpenFileAction.java:179)
at com.android.tools.idea.actions.AndroidOpenFileAction.doOpenFile(AndroidOpenFileAction.java:149)
at com.android.tools.idea.actions.AndroidOpenFileAction.lambda$actionPerformed$0(AndroidOpenFileAction.java:111)
at com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl.choose(FileChooserDialogImpl.java:146)
at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:102)
at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:80)
at com.android.tools.idea.actions.AndroidOpenFileAction.actionPerformed(AndroidOpenFileAction.java:101)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:239)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:260)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:239)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil.performAnActionForComponent(WelcomeScreenActionsUtil.java:96)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil$LargeIconWithTextWrapper.lambda$new$0(WelcomeScreenActionsUtil.java:125)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:270)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
at java.desktop/java.awt.Component.processEvent(Component.java:6419)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2790)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:820)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:757)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```
What happens on line 303 of WelcomeScreenComponentFactory.java:303 ?
In general a NPE or null pointer exception happens when you attempt to reference a method or property of an variable in code and that variable is not initialized or is pointing at null. if on line 303 you have someObject.someMethod() then can infer that someObject was null when the line was run. Sounds like when you're calling that library method the object being passed to it is null, but can maybe run in debug mode and step back through the stack trace to see what call/setup your app made before the exception is thrown as well.

Creating Android WebView in NativeActivity with JNI in rust

I'm trying to connect a android.webkit.WebView object to a NativeActivity, but I'm failing simply trying to create the WebView object. That code looks like this
#[cfg(target_os = "android")]
pub fn setup(ctx: AndroidContext, env: AttachGuard) -> JObject {
let class = env.find_class("android/webkit/WebView").unwrap();
let context: *mut _jobject = ctx.context().cast();
let webview = env
.new_object(
class,
"(Landroid/content/Context;)V",
&[JValue::Object(context.into())],
)
.unwrap();
env.call_method(
context,
"setContentView",
"(Landroid/view/View;)V",
&[webview.into()],
)
.unwrap()
.v()
.unwrap();
...
}
When I try to create the WebView I see this crash with logcat
06-26 23:17:30.471 30695 30727 E AndroidRuntime: FATAL EXCEPTION: Thread-2
06-26 23:17:30.471 30695 30727 E AndroidRuntime: Process: rust.example.android, PID: 30695
06-26 23:17:30.471 30695 30727 E AndroidRuntime: java.lang.RuntimeException: WebView cannot be initialized on a thread that has no Looper.
06-26 23:17:30.471 30695 30727 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:670)
06-26 23:17:30.471 30695 30727 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:604)
06-26 23:17:30.471 30695 30727 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:587)
06-26 23:17:30.471 30695 30727 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:574)
06-26 23:17:30.471 30695 30727 E AndroidRuntime: at android.webkit.WebView.<init>(WebView.java:564)
It appears that from the context on the rust side there is a looper (based on getting the ThreadLooper via a call to for_thread and checking that it's not storing a null pointer). However it does appear that there isn't one from the JVM perspective since attempts to log the results of a call to myLooper on the android.os.Looper object via JNI yields a null looper. I suppose this makes sense since the UI loop was not setup the way it normally would be with a Java / Kotlin Android app. The question is, is there a way around this?
Can I execute the JNI calls within a context that's part of the the non-null looper, or share that looper with the JNI context, or create a looper via JNI for the context within the JVM. Since this is supposed to be part of a rust library I'm try to avoid needing to add any java boiler plate. Is there a way to avoid that? I'm not exactly an Android or JNI expert so I'm pretty far out over my skis with this project. Any help is appreciated.
By far the simplest solution is simply to launch a new (non-native) activity for the duration of the web interaction.
If you cannot do that, you will have to do (at least) the following:
Call the Java Looper.prepare() method to associate your thread with a Looper
Instantiate the WebView component
Set up the necessary callbacks such that eventually quit() is called on the Looper instance
Give up control of the current thread with Looper.loop().

Android WebView App :: Errors Name : File error accessing recents directory ; Task 255 failed or timed out ; CancellationException

I have lots of links in my app, I have used the Firebase database for data fetch and data send and also used broadcast receiver.
Most of the time my app is not crashing with these errors, but sometimes it crashed. When it crashed, I opened the logcat the I found this
2022-04-22 02:22:46.387 1260-1445/? E/WifiVendorHal: getWifiLinkLayerStats_1_3_Internal(l.974) failed {.code = ERROR_NOT_SUPPORTED, .description = }
2022-04-22 02:32:18.834 18124-18124/? E/A: Task 255 failed or timed out. Client 79711845498329053 disconnecting from SearchService!
java.util.concurrent.CancellationException: Task was cancelled.
at com.google.common.util.concurrent.d.s(PG:3)
at com.google.common.util.concurrent.d.get(PG:4)
at com.google.common.util.concurrent.eb.a(PG:1)
at com.google.common.util.concurrent.ci.r(PG:2)
at com.google.common.util.concurrent.cb.run(PG:4)
at com.google.android.apps.gsa.shared.util.c.a.ba.run(PG:1)
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:8653)
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)
2022-04-22 02:32:18.838 18124-18124/? E/A: Task 255 failed or timed out. Client 79711845498329051 disconnecting from SearchService!
java.util.concurrent.CancellationException: Task was cancelled.
at com.google.common.util.concurrent.d.s(PG:3)
at com.google.common.util.concurrent.d.get(PG:4)
at com.google.common.util.concurrent.eb.a(PG:1)
at com.google.common.util.concurrent.ci.r(PG:2)
at com.google.common.util.concurrent.cb.run(PG:4)
at com.google.android.apps.gsa.shared.util.c.a.ba.run(PG:1)
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:8653)
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)
2022-04-22 02:32:18.850 18124-17677/? E/BgTaskExecutorImpl: PERIODIC background task MDD_CELLULAR_CHARGING_TASK was cancelled.
java.util.concurrent.CancellationException: Task was cancelled.
at com.google.common.util.concurrent.d.s(PG:3)
at com.google.common.util.concurrent.d.get(PG:4)
at com.google.common.util.concurrent.eb.a(PG:1)
at com.google.common.util.concurrent.ci.r(PG:2)
at com.google.common.util.concurrent.cb.run(PG:4)
at com.google.android.apps.gsa.shared.util.c.a.cf.b(PG:1)
at com.google.android.apps.gsa.shared.util.c.a.ci.run(PG:1)
at com.google.android.libraries.i.ae.run(PG:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.libraries.i.i.run(PG:2)
at com.google.android.libraries.i.p.run(PG:4)
at java.lang.Thread.run(Thread.java:923)
2022-04-22 02:32:18.857 18124-17615/? E/BgTaskExecutorImpl: PERIODIC background task MDD_WIFI_CHARGING_TASK was cancelled.
java.util.concurrent.CancellationException: Task was cancelled.
at com.google.common.util.concurrent.d.s(PG:3)
at com.google.common.util.concurrent.d.get(PG:4)
at com.google.common.util.concurrent.eb.a(PG:1)
at com.google.common.util.concurrent.ci.r(PG:2)
at com.google.common.util.concurrent.cb.run(PG:4)
at com.google.android.apps.gsa.shared.util.c.a.cf.b(PG:1)
at com.google.android.apps.gsa.shared.util.c.a.ci.run(PG:1)
at com.google.android.libraries.i.ae.run(PG:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.libraries.i.i.run(PG:2)
at com.google.android.libraries.i.p.run(PG:4)
at java.lang.Thread.run(Thread.java:923)
sometimes it shows this also
2022-04-22 09:28:15.894 1928-2047/? E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
2022-04-22 09:49:15.232 21150-21150/ W/System.err: at w.Internet_Checker_BroadCast_Reciver.onReceive(Internet_Checker_BroadCast_Reciver.java:27)
I have studied it more. I found a thing , when the app is crashing the logcat prints as the last line is(will it be the reason?) :
2022-04-22 12:22:25.941 17481-17552/w D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: null

Why does my app crash after using MediaPlayer after hitting a button?

This is my first post on stack overflow. So my app keeps stopping after I hit a button that should play a censor noise. It just crashes.
I tried looking up various solutions but nothing is coming up.
package com.example.soundbutton;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity{
Button bleep;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bleep = (Button) findViewById(R.id.bleep);
final MediaPlayer bleepMP = MediaPlayer.create(this, R.raw.censor);
bleep.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View V) {
bleepMP.start();
}
});
}
}
Below is information after running through and emulator. I am still not too sure what exactly i am looking at. From what i can infer, it would seem as if i am pointing to some null value. I tried initializing the mp value as a null and setting a condition where if it were null, then it would start the onclick.
Here is the information after running in an emulator `code`11/20 14:20:48: Launching 'app' on Pixel XL API 29.
$ adb shell am start -n "com.example.soundbutton/com.example.soundbutton.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 21565 on device 'emulator-5554'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/ple.soundbutto: Not late-enabling -Xcheck:jni (already on)
E/ple.soundbutto: Unknown bits set in runtime_flags: 0x8000
W/ple.soundbutto: Unexpected CPU variant for X86 using defaults: x86
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
W/RenderThread: type=1400 audit(0.0:53): avc: denied { write } for name="property_service" dev="tmpfs" ino=7228 scontext=u:r:untrusted_app:s0:c136,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.soundbutton
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/ple.soundbutto: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
E/MediaPlayerNative: error (1, -2147483648)
D/MediaPlayer: create failed:
java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer._prepare(Native Method)
at android.media.MediaPlayer.prepare(MediaPlayer.java:1274)
at android.media.MediaPlayer.create(MediaPlayer.java:977)
at android.media.MediaPlayer.create(MediaPlayer.java:948)
at com.example.soundbutton.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/HostConnection: HostConnection::get() New Host Connection established 0xd9bd3fa0, tid 21629
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xe51d4400: maj 3 min 1 rcv 4
D/EGL_emulation: eglMakeCurrent: 0xe51d4400: ver 3 1 (tinfo 0xf04c02e0)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
glUtilsParamSize: unknow param 0x000082da
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0xd9bd5800, tid 21629
HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1
D/eglCodecCommon: allocate: Ask for block of size 0x1000
D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff1dc000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xe51d4400: ver 3 1 (tinfo 0xf04c02e0)
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
I/Choreographer: Skipped 43 frames! The application may be doing too much work on its main thread.
W/MediaPlayer-JNI: MediaPlayer finalized without being released
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.soundbutton, PID: 21565
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference
at com.example.soundbutton.MainActivity$1.onClick(MainActivity.java:25)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Process 21565 terminated.

How do I remove a test step using groovy in soapUI

Can someone please advise how to remove a test step in SoapUI using groovy?
In my project, I have a REST test request that gets generated and executed on the fly. Once the request has been submitted, I would like to automatically remove this step using groovy script.
I tried something like:
testRunner.testCase.removeTestStep( "Trigger_REST_Request" );
But this returns error:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.removeTestStep()
is applicable for argument types: (java.lang.String) values: [Trigger_REST_Request]
Possible solutions:
removeTestStep(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep),
moveTestStep(int, int) groovy.lang.MissingMethodException
Thanks!
Well that worked....sort of. When I added the suggested two lines, I can see that the test step is removed, however, I'm also receiving a NullPointerException now. As a result the test suite exits after NPE is returned. This is the NPE error I get:
Wed Sep 21 09:27:11 EST 2016:ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at com.eviware.soapui.model.support.ModelSupport.dependsOn(ModelSupport.java:196)
at com.eviware.soapui.impl.wsdl.teststeps.actions.ShowMessageExchangeAction$MessageExchangeDesktopPanel.dependsOn(ShowMessageExchangeAction.java:203)
at com.eviware.soapui.ui.desktop.AbstractSoapUIDesktop.closeDependantPanels(AbstractSoapUIDesktop.java:101)
at com.eviware.soapui.ui.desktop.AbstractSoapUIDesktop$InternalTestSuiteListener.testStepRemoved(AbstractSoapUIDesktop.java:190)
at com.eviware.soapui.impl.wsdl.WsdlTestSuite.fireTestStepRemoved(WsdlTestSuite.java:277)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.removeTestStep(WsdlTestCase.java:577)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase$removeTestStep.call(Unknown Source)
at Script9.run(Script9.groovy:19)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If you need to remove the test step, use the following code:
def tc = testRunner.testCase
def tbr = tc.getTestStepByName('ToBeRemoved')
if (tbr != null) {
tc.removeTestStep(tbr)
}
The script handles also the case when the ToBeRemoved test step does not exist.

Resources