How can I black-box a library in the android debugger - android

I'm using khttp to perform HTTP requests in my Android app, but every time I start adding breakpoints to my app in Android Studio 3.1, I'm getting this really annoying Illegal State Exception, at which point I them need to restart Android Studio. Here's an example of the exception thrown:
E/AndroidRuntime: FATAL EXCEPTION: Thread-4
Process: com.sbrl.peppermint, PID: 10777
java.lang.IllegalStateException: Cannot access request header fields after connection is set
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getRequestProperties(HttpURLConnectionImpl.java:232)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getRequestProperties(DelegatingHttpsURLConnection.java:182)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getRequestProperties(Unknown Source:0)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.getRequestProperties(TrackedHttpURLConnection.java:204)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.trackPreConnect(TrackedHttpURLConnection.java:63)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.connect(TrackedHttpURLConnection.java:126)
at com.android.tools.profiler.support.network.httpurl.HttpsURLConnection$.connect(HttpsURLConnection$.java:366)
at khttp.responses.GenericResponse.openRedirectingConnection$khttp(GenericResponse.kt:125)
at khttp.responses.GenericResponse.getConnection(GenericResponse.kt:163)
at khttp.responses.GenericResponse.getRaw(GenericResponse.kt:207)
at khttp.responses.GenericResponse.getContent(GenericResponse.kt:216)
at khttp.responses.GenericResponse.init$khttp(GenericResponse.kt:377)
at khttp.KHttp.request(KHttp.kt:61)
at khttp.KHttp.request$default(KHttp.kt:59)
I know that this question explains why this is happening, but my question is this:
How can I black-box the khttp library (similar to the way that Chrome allows you to black-box a JS source file), such that the Android debugger does not inspect it - throwing this exception?

Related

Authentification in Android App without user login

I am trying to implement a dialogsystem (Google Dialogflow CX) into an Android App. I am trying to connect via REST. Appparently, CX doesn't support API keys and the library commonly used is not supported in Android either, so I am facing problems.
With the credentials available in raw (implementation as previously used with dialogflow ES), I get the following error message:
07-09 12:10:27.841 2600-2600/com.softbankrobotics.jokeswithdialogflow E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.softbankrobotics.jokeswithdialogflow, PID: 2600
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration;
at com.google.auth.oauth2.OAuth2Credentials.<clinit>(OAuth2Credentials.java:70)
at com.google.auth.oauth2.ServiceAccountCredentials.fromStream(ServiceAccountCredentials.java:475)
at com.softbankrobotics.jokeswithdialogflow.data.DialogflowDataSource.<init>(DialogflowDataSource.kt:17)
at com.softbankrobotics.jokeswithdialogflow.MainActivity.onCreate(MainActivity.kt:52)
at android.app.Activity.performCreate(Activity.java:6257)
...
It seems the first error refers to the min SDK having to be at 26. Unfortunately, I need 23 for my app to run on pepper robot - so I can't alter this.
I would like to authenticate once (e.g. with my own Google account), with validity for all the test users. Safety aspects can be disregarded here, as the implementation is intended for testing in a scientific study, only.
Thank you in advance - any help is appreciated!

java.lang.noclassdeffounderror with libgdx and Android studio on the androidLauncher

I imported a package of my own called server (the logic of my program) and was going to use libgdx for the graphics/cross platform. The desktop launcher works fine but when I run the android launcher I get this nasty error referring to my own library.
E/AndroidRuntime: FATAL EXCEPTION: GLThread 187
Process: com.mygdx.game, PID: 8093
java.lang.NoClassDefFoundError: server.Point
at server.Shape.<init>(Shape.java:9)
at server.T.<init>(T.java:7)
at server.Stack.<init>(Stack.java:28)
at server.Logic.<init>(Logic.java:14)
at com.mygdx.game.GameLoop.create(GameLoop.java:43)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1511)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
any help would be great
I solved it!
It was because I was using java.awt.point in the android build. So I basically wrote a new point class, replace it, and then cleaned my project. Everything works now

Trigger.io bluetooth permission?

I am working with a bluetooth hardware device and I am trying to get it to interface with my Trigger.IO application. It seems as though it is not possible, even though technically it should. Here are my steps so far:
Used the Trigger.IO module functionality to create a module which was able to successfully send and receive messages between the Trigger.IO app and native Java code
Created a native Android application which successfully communicated with the bluetooth hardware device
Ported my native Android bluetooth code over into my Trigger.IO module
At this point the custom module is included in the Trigger app and seems to starting correctly, but when I make a call that should initiate the bluetooth device connection logic I am getting errors about bluetooth permissions. I ensured that my module has the necessary bluetooth permissions within its AndroidManifest.xml, but my fear is that the base Trigger app does not have the required permissions.
These are logs that output within the LogCat when the attempting to start the bluetooth connection:
D/Forge: Native call module.startDevicePolling with task.params: {}
D/BluetoothManagerService: Message: 20
D/BluetoothManagerService: Added callback: Android.bluetooth.IBluetoothManagerCallback$Stub$Proxy#41f84218:true
W/dalvikvm: threadid=25: thread exiting with uncaught exception (group=0x41612ba8)
I/Process: Sending signal. PID: 11967 SIG: 9
E/AndroidRuntime: FATAL EXCEPTION: Incoming Data Thread
E/AndroidRuntime: Process: io.trigger.forge42a1430afae511e2a0e61231392b77b0, PID: 11967
E/AndroidRuntime: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10230 nor current process has android.permission.BLUETOOTH.
Looking at the AndroidManfiest.xml at the root of the deployed .APK it looks as though Trigger only has permissions for INTERNET and ACCESS_NETWORK_STATE. Anyone else run into this? I think if I can get the BLUETOOTH permission into the root AndroidManifest.xml that things will work, but that file is encoded to not make that easy.
Trigger.io does support the ability for module's to add permissions - see Changing build configuration
In summary:
Add a build steps file in android/build_steps.json
For your scenario, update the build steps file with: [ { "do": { "android_add_permission": { "permission": "android.permission.BLUETOOTH" } } } ]
After changing the build steps for either Android or iOS it is important to update the inspector project
I was able to solve my problem by changing the local trigger android template to give me the permission I needed. This is obviously not ideal. It would be ideal to have the Trigger logic look at the native modules, derive the required permissions, and update their master AndroidManifest.xml accordingly.

NullPointerException while using Monkeytalk tool

Hello I have implemented MonkeyTalk library in my app I used following steps given at https://www.gorillalogic.com/monkeytalk-documentation/monkeytalk-getting-started/install-agent/android.
Through these steps i am successfully able to record and playback steps in monkey talk IDE.
Now issue is when i use my app after installing the library it crashes randomly at several places giving NullPointerException. Log of one such incident is given below:
05-08 19:29:13.661: E/AndroidRuntime(27158): FATAL EXCEPTION: Thread-4790
05-08 19:29:13.661: E/AndroidRuntime(27158): java.lang.NullPointerException
05-08 19:29:13.661: E/AndroidRuntime(27158): at com.gorillalogic.fonemonkey.ActivityManager$2.run(ActivityManager.java:112)
05-08 19:29:13.661: E/AndroidRuntime(27158): at java.lang.Thread.run(Thread.java:856)
Any help to resolve the issue would be greatly appreciated.
I am using Eclipse Juno and Target SDK is 4.2 for development.
I got the same error when I tried to invoke another application (which does not have Monkey Talk Agent) from our application which is integrated with Monkey Talk Agent. So I have added a null pointer check in the monkey talk source code and that fixed the problem.
ActivityManager.cjava - checkIsClipped() function:
// Adding a null pointer check for the case where the application invokes another application that does not have
// MonkeyTalk Agent integrated (for eg: Zxing barcode scanner). In this case the top activity would be null.
catch (NullPointerException e) {
e.printStackTrace();
}

Android UI Crash due to kernel error

When I return error from linux system calls like create/open etc. in order to fail such operations from my App, complete Android UI crashes. When I investigated more I realized that root cause is the system_server crashing because of my errors from system call.
I tried using errors like EACCESS, EBADF etc but each of these seems to be considered as a fatal exception by Android!
Any idea on non-fatal error values which I can use such that it does not cause Android UI to crash?

Categories

Resources