NullPointerException while using Monkeytalk tool - android

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();
}

Related

How to get the full information of runtime error instead of <Timeout exceeded getting exception details>?

So I'm trying out xamarin in VS2017, but found this undhandled error:
Unhandled Exception:
Java.Lang.SecurityException: <Timeout exceeded getting exception details>
This is very clueless. How can I get the full information of the runtime error like in Android Studio?
I had the same problem while calling some native API,
solved it by
Put a try catch around the block of got which is throwing the error.
Put a breakpoint in the catch block, you can get actual details of the exception.
After getting assistance from Microsoft, I finally found the solution.
TL;DR
Use VS Android device log and filter with "mono-rt" or "Error"
Complete Answer:
There are 2 solution:
1. Using Android Studio logcat:
Open the Android Studio logcat (View > Tool Windows > Logcat). From the logcat window, choose the device, choose the Xamarin.Android deployed application, and choose logcat for Error
Android logcat will display the runtime error:
2. Using Visual Studio Android Device Log:
Open the Visual Studio Android Device Log(Tools > Android > Device Log).
Here is the tricky bit: Unlike Android Studio, VS list all of the device log, not limited to the Xamarin.Android app deployed. So somehow we have to use the filter to get the relevant information. The problem is, what filter should we use? I used my application name and the error didn't show up. It turns out that when the error happen, the log doesn't contain any of the application name. Instead it has "mono-rt" tag with "Error" type.
So there you have it. Filter it with "mono-rt" tag or "Error" type and you will find the error information

Android facebook sdk internal utility java.lang.AssertionError

I have been using version 4.27.0 of facebook sdk for android. I have been getting a crash only for android 8+ devices. The stack trace is as follows:
Fatal Exception: java.lang.AssertionError: No NameTypeIndex match for SHORT_DAYLIGHT
at android.icu.impl.TimeZoneNamesImpl$ZNames.getNameTypeIndex(TimeZoneNamesImpl.java:724)
at android.icu.impl.TimeZoneNamesImpl$ZNames.getName(TimeZoneNamesImpl.java:790)
at android.icu.impl.TimeZoneNamesImpl.getTimeZoneDisplayName(TimeZoneNamesImpl.java:183)
at android.icu.text.TimeZoneNames.getDisplayName(TimeZoneNames.java:261)
at java.util.TimeZone.getDisplayName(TimeZone.java:405)
at java.util.TimeZone.getDisplayName(TimeZone.java:370)
at com.facebook.internal.Utility.refreshTimezone(Utility.java:1066)
at com.facebook.internal.Utility.refreshPeriodicExtendedDeviceInfo(Utility.java:1056)
at com.facebook.internal.Utility.setAppEventExtendedDeviceInfoParameters(Utility.java:707)
at com.facebook.internal.AppEventsLoggerUtility.getJSONObjectForGraphAPICall(AppEventsLoggerUtility.java:68)
at com.facebook.FacebookSdk.publishInstallAndWaitForResponse(FacebookSdk.java:568)
at com.facebook.FacebookSdk$4.run(FacebookSdk.java:547)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I have searched for this over the web but couldn't get anything useful. Please provide some pointers here.
I am facing this issue too, upgrade the Facebook SDK to the latest (Facebook Android SDK 4.35), they have added a workaround for this issue:
private static void refreshTimezone() {
try {
TimeZone tz = TimeZone.getDefault();
deviceTimezoneAbbreviation = tz.getDisplayName(
tz.inDaylightTime(new Date()),
TimeZone.SHORT
);
deviceTimeZoneName = tz.getID();
} catch (AssertionError e) {
// Workaround for a bug in Android that can cause crashes on Android 8.0 and 8.1
} catch (Exception e) {
}
}
Yes, Even I am facing this kind of issue in my app while using volley library, Coming in devices having Android 8.0.1 version.
Fatal Exception: java.lang.AssertionError
No NameTypeIndex match for SHORT_STANDARD
android.icu.impl.TimeZoneNamesImpl$ZNames.getNameTypeIndex
(TimeZoneNamesImpl.java:724)
android.icu.impl.TimeZoneNamesImpl$ZNames.getName
(TimeZoneNamesImpl.java:790)
android.icu.impl.TimeZoneNamesImpl.getTimeZoneDisplayName
(TimeZoneNamesImpl.java:183)
android.icu.text.TimeZoneNames.getDisplayName (TimeZoneNames.java:261)
java.text.SimpleDateFormat.subFormat (SimpleDateFormat.java:1296)
java.text.SimpleDateFormat.format (SimpleDateFormat.java:1004)
java.text.SimpleDateFormat.format (SimpleDateFormat.java:974)
java.text.DateFormat.format (DateFormat.java:341)
com.android.volley.toolbox.HttpHeaderParser.formatEpochAsRfc1123
(HttpHeaderParser.java:152)
com.android.volley.toolbox.BasicNetwork.getCacheHeaders
(BasicNetwork.java:256)
com.android.volley.toolbox.BasicNetwork.performRequest
(BasicNetwork.java:130)
com.android.volley.NetworkDispatcher.processRequest
(NetworkDispatcher.java:120)
com.android.volley.NetworkDispatcher.run (NetworkDispatcher.java:87)
When I raised this issue on volley github, after checking they responded that this is device framework issue, means manufacture customized os bug.
I feel we both are facing the same issue, as the lines where the bug actually starts is "android.icu.text.TimeZoneNames.getDisplayName(TimeZoneNames.java:261)" is same in both of our stacktraces. This is more of ICU package issue that is embedded in the framework. I found one personally forked Git class of a google developer which is a class of IBM icu, where the line number 722 " throw new AssertionError("No NameTypeIndex match for " + type);" is actually throwing the error in both of our cases. Let's hope Google comes up with the fixes or any workaround for the same. I may be wrong in my observation, do your own research.

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

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?

Provisioning Nymi band from Android app

I am trying to provision the Nymi band from my android app. I am using the sample code from the Nymi Android SDK 2.0 (Can be downloaded from here:). I removed all the code related to the Nymulator(Nymi band emulator). I want to test the provisioning with the real Nymi band. However,when I click the provision button, the app get crashed. I tried to debug it with the exception breakpoints and I got the "getsockopt errno 88" error in my debugger:
I am attaching the screenshot too.
I did some research on google , and found that the errno 88 is
#define ENOTSOCK 88 /* Socket operation on non-socket */
During the app launch, I see the following message in the Debug Console:
Connected to the target VM, address: 'localhost:8604', transport: 'socket'
which I think,the connection to socket is fine. I am not sure,what makes the socket connection go wrong later.
This is what I see in my LOgCat after I click the provision button:(I am posting only some part of the error message,because the error message in Logcat is way too long)
Edit: I added some breakpoints,and I found where the app is crashing. I found this code:
try {
System.loadLibrary("_nymi_sdk_net");
_loaded = true;
} catch (UnsatisfiedLinkError var6) {
return false;
}
At system.load library, I am getting the error.
Edit 2: I changed the libraries from net to native ,as net is for emulators and native is for device. This time new error occurs at the same line:System.loadLibrary("_nymi_sdk");
Screenshot:
(Disclaimer: I know nothing of this SDK or the band, and this answer is just a speculation. And I've deleted my earlier answer as it was a missed shot in the dark.)
There is a minor hint in the SDK's README.md:
Prerequisites:
Android Development:
[...]
To use the BasicExample app with a Nymi Band, the NCL library in Examples\BasicExample\libs must be replaces with the native library in
NCL\native\libs
You must remove all files and folders from BasicExample\libs and copy all files from NCL\native\libs there instead.
(I wonder why they didn't emphasize this much harder...)
So the libs folder should contain the following folders and files:

Unsatisfied link error for native library

I developed applications which use native code. All of a sudden those are not working, giving error "Unsatisfied link error: Couldn't load native library from loader dalvik.System.pathClassLoader, findLibrary returned null. I restarted adt twice. Still getting the same error. Applications which are not using native code, are working fine.
The error implies that the program is not able to find the shared libraries that you would have created.
Which devices did you try it on ?
You can check once if they are available in libs directory of your app . [/data/data/app_id/lib ]. Also check if armv7 support is required and if the directory is there in the libs , is .so present there.
Now it's working. I deleted all my virtual devices and then created a new one. However it's showing "skipped 264 frames. application may be doing too much work on main thread" many times and whenever we press a button, displaying this message in log "error loading /system/media/audio/ui/Effect_Tick.ogg"
thanks.

Categories

Resources