Emma code coverage for Android manual testing - android

I tried setting up my project using instructions on below post by Diego:
http://dtmilano.blogspot.com/2011/11/obtaining-code-coverage-of-running.html
On trying to launch the app using adb shell am instrument -e coverage true -w ...
I get below error:
E/Trace ( 3989): error opening trace file: No such file or directory (2)
W/Trace ( 3989): Unexpected value from nativeGetEnabledTags: 0
W/Trace ( 3989): Unexpected value from nativeGetEnabledTags: 0
W/Trace ( 3989): Unexpected value from nativeGetEnabledTags: 0
I/dalvikvm( 3989): ****Could not find method com.vladium.emma.rt.RT.r, referenced from method com.adobe.dps.coverage.EmmaInstrumentation.$VRi
W/dalvikvm( 3989): VFY: unable to resolve static method 27137: Lcom/vladium/emma/rt/RT;.r ([[ZLjava/lang/String;J)V
D/dalvikvm( 3989): VFY: replacing opcode 0x71 at 0x004b
W/dalvikvm( 3989): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/adobe/dps/coverage/EmmaInstrumentation;
W/dalvikvm( 3989): Class init failed in newInstance call (Lcom/adobe/dps/coverage/EmmaInstrumentation;)
D/AndroidRuntime( 3989): Shutting down VM
W/dalvikvm( 3989): threadid=1: thread exiting with uncaught exception (group=0xb4cc7908)
E/AndroidRuntime( 3989): FATAL EXCEPTION: main
E/AndroidRuntime( 3989): java.lang.ExceptionInInitializerError
I included emma.jar in the build path and deployed it inside the app and got below error:
E/Trace ( 4061): error opening trace file: No such file or directory (2)
W/Trace ( 4061): Unexpected value from nativeGetEnabledTags: 0
W/Trace ( 4061): Unexpected value from nativeGetEnabledTags: 0
W/Trace ( 4061): Unexpected value from nativeGetEnabledTags: 0
W/dalvikvm( 4061): ****Exception Ljava/lang/Error; thrown while initializing Lcom/vladium/emma/rt/RT;
W/dalvikvm( 4061): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lcom/package/coverage/EmmaInstrumentation;
W/dalvikvm( 4061): Class init failed in newInstance call (Lcom/package/coverage/EmmaInstrumentation;)
D/AndroidRuntime( 4061): Shutting down VM
W/dalvikvm( 4061): threadid=1: thread exiting with uncaught exception (group=0xb4cc7908)
E/AndroidRuntime( 4061): FATAL EXCEPTION: main
E/AndroidRuntime( 4061): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 4061): at java.lang.Class.newInstanceImpl(Native Method)
Any idea how I could resolve this?
Thanks!

It seems you should execute this command:
"ant instrument"
because you have such an error info: ****Could not find method com.vladium.emma.rt.RT.r

Below link helped me to resolve the issue. I am using so added the below dependencies:
Added the below dependency in the build.gradle file present in the app folder.
compile group: 'org.jruby', name: 'jruby', version: '1.4.1'
And the below dependency in the build.gradle file present at the project folder.
maven {
url "https://repo1.maven.org/maven2/"
}
Choose your dependency from the below link:
http://snacktrace.com/artifacts/org.jruby/jruby/1.4.1/com.vladium.emma.rt.RT

Related

Current AndroidStudio sample fails on phone due to runtime native library link error. Why?

Its on an HTC Aria, running 2.2 (API 8)
https://en.wikipedia.org/wiki/HTC_Aria
The aria is an armv6 device that supports opengles 2
If you open up the latest Android Studio (im working on windows 7), then import the HelloGL2 sample, then simply try to run it on the above device, it will fail as soon as it tries to make a call into the native library.
Here is the log:
01-06 11:14:08.467 12771-12813/com.android.gl2jni D/dalvikvm: Trying to load lib /data/data/com.android.gl2jni/lib/libgl2jni.so 0x44c165d0
01-06 11:14:08.467 12771-12813/com.android.gl2jni I/dalvikvm: Unable to dlopen(/data/data/com.android.gl2jni/lib/libgl2jni.so): Cannot load library: link_image[1995]: failed to link libgl2jni.so
01-06 11:14:08.477 12771-12813/com.android.gl2jni W/dalvikvm: Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/android/gl2jni/GL2JNILib;.<clinit>
01-06 11:14:08.497 12771-12813/com.android.gl2jni W/dalvikvm: threadid=8: thread exiting with uncaught exception (group=0x40028a00)
01-06 11:14:08.517 95-121/? I/ActivityManager: Displayed activity com.android.gl2jni/.GL2JNIActivity: 9823 ms (total 2027818 ms)
01-06 11:14:08.567 12771-12813/com.android.gl2jni E/AndroidRuntime: FATAL EXCEPTION: GLThread 9
java.lang.ExceptionInInitializerError
at com.android.gl2jni.GL2JNIView$Renderer.onSurfaceChanged(GL2JNIView.java:332)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1327)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
Caused by: java.lang.UnsatisfiedLinkError: Library gl2jni not found
at java.lang.Runtime.loadLibrary(Runtime.java:461)
at java.lang.System.loadLibrary(System.java:557)
at com.android.gl2jni.GL2JNILib.<clinit>(GL2JNILib.java:24)
at com.android.gl2jni.GL2JNIView$Renderer.onSurfaceChanged(GL2JNIView.java:332) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1327) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 
01-06 11:14:08.607 95-164/? W/ActivityManager: Force finishing activity com.android.gl2jni/.GL2JNIActivity
This sample works on the 3 other devices i've tried (Galaxy s5, Galaxy J1, Nexus s)
The line: 'Unable to dlopen(/data/data/com.android.gl2jni/lib/libgl2jni.so): Cannot load library: link_image[1995]: failed to link libgl2jni.so' is probably key. I tried loading the library explicitly using system.loadlibrary, but the same problem happens on that call.
I think it might be something to do with the processor being armv6?
The sample is configured to do 'armeabi' though.

android adt 17 - add jar to project - jar in dexedlibs/ only contains a manifest

i am using a 3 day old download of adt 17 on win 7 x64 with java 1.7.
adding a jar to my new sample project (by copying it to libs/) compiles fine, but throws at runtime because the classes in the jar are not in the corresponding jar in dexedlibs/ - that jar only contains a manifest.
related links: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17 and http://tools.android.com/recent/dealingwithdependenciesinandroidprojects.
doing some of the export and order stuff suggested in the links does not help.
how does one know how to add a jar to an android project these days?
edit: thanks to max: the jar was made using java 1.7, specifying 1.6 stopped the throwing, but i still get some missing methods for some reason (these are not called, but they are referenced).
12-20 23:02:13.689: W/Trace(27907): Unexpected value from nativeGetEnabledTags:
12-20 23:02:13.689: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:13.689: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:13.949: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:13.949: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:14.829: I/dalvikvm(27907): Could not find method com.tayek.utilities.Utilities.store, referenced from method com.tayek.qanda.Model.toPropertiesFile
12-20 23:02:14.829: W/dalvikvm(27907): VFY: unable to resolve static method 3399: Lcom/tayek/utilities/Utilities;.store (Ljava/io/File;Ljava/util/Properties;)V
12-20 23:02:14.829: D/dalvikvm(27907): VFY: replacing opcode 0x71 at 0x000f
12-20 23:02:14.849: I/dalvikvm(27907): Could not find method com.tayek.utilities.Utilities.store, referenced from method com.tayek.qanda.Model.toPropertiesFile
12-20 23:02:14.849: W/dalvikvm(27907): VFY: unable to resolve static method 3399: Lcom/tayek/utilities/Utilities;.store (Ljava/io/File;Ljava/util/Properties;)V
12-20 23:02:14.849: D/dalvikvm(27907): VFY: replacing opcode 0x71 at 0x0014
12-20 23:02:14.849: I/dalvikvm(27907): Could not find method com.tayek.utilities.Utilities.store, referenced from method com.tayek.qanda.Model.toPropertiesFile
12-20 23:02:14.849: W/dalvikvm(27907): VFY: unable to resolve static method 3400: Lcom/tayek/utilities/Utilities;.store (Ljava/io/Writer;Ljava/util/Properties;)V
12-20 23:02:14.849: D/dalvikvm(27907): VFY: replacing opcode 0x71 at 0x000f
12-20 23:02:14.849: I/dalvikvm(27907): Could not find method com.tayek.utilities.Utilities.store, referenced from method com.tayek.qanda.Model.toPropertiesFile
12-20 23:02:14.849: W/dalvikvm(27907): VFY: unable to resolve static method 3400: Lcom/tayek/utilities/Utilities;.store (Ljava/io/Writer;Ljava/util/Properties;)V
12-20 23:02:14.849: D/dalvikvm(27907): VFY: replacing opcode 0x71 at 0x0014
12-20 23:02:14.929: I/System.out(27907): Hospital Mortality Risk
12-20 23:02:14.969: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:14.969: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:14.969: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:14.989: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.029: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.029: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.040: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.160: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.160: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.160: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.169: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.169: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.169: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.189: D/gralloc_goldfish(27907): Emulator without GPU emulation detected.
12-20 23:02:15.258: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
12-20 23:02:15.299: W/Trace(27907): Unexpected value from nativeGetEnabledTags: 0
update: importing a jar with trivial classes works fine.
If you are using Java 7 you can try changing the runtime environment for the Java library project:
Right click and the project -> Properties -> Java Build Path -> Libraries
Choose JRE System Library [JavaSE-1.7] and click edit
Change execution environment to JavaSE-1.6 (jre7)
This worked for me using ADT 21.

try to access android.os.Build.SERIAL if available

Below is some code that I use to access Build.SERIAL static field, but it crashes when runs on Android 1.6!
// introduced in Android 2.3(API Level 9)
if (Integer.parseInt(android.os.Build.VERSION.SDK) >= android.os.Build.VERSION_CODES.GINGERBREAD) {
deviceID = android.os.Build.SERIAL; //cannot execute here if runs on Android 1.6!!!
}
That's the crash logs:
DexOpt: couldn't find static field
W/dalvikvm( 1098): VFY: unable to resolve static field 37 (SERIAL) in Landroid/os/Build;
W/dalvikvm( 1098): VFY: rejecting opcode 0x62 at 0x0001
W/dalvikvm( 1098): VFY: rejected Lcom/opera/mini/android/DisplayNotificationService;.getDeviceSerialID ()Ljava/lang/String;
W/dalvikvm( 1098): Verifier rejected class Lcom/opera/mini/android/DisplayNotificationService;
W/dalvikvm( 1098): Class init failed in newInstance call (Lcom/opera/mini/android/DisplayNotificationService;)
D/AndroidRuntime( 1098): Shutting down VM
W/dalvikvm( 1098): threadid=3: thread exiting with uncaught exception (group=0x4001da10)
E/AndroidRuntime( 1098): Uncaught handler: thread main exiting due to uncaught exception`
So how to resolve this problem?
If you check the Android documentation , android.os.Build.VERSION_CODES.GINGERBREAD is supported since API level 9 (Gingerbread). Remove it from the If condition and do the check another way. For e.g. check that if SDK is greater than DONUT, then do something else get the serial.
Update:
I mean try like this for e.g.:
if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 9) {
deviceID = android.os.Build.SERIAL;
}
Use SDK_INT not SDK, as it's an integer not a string and removes the comparison issues you are suffering from.
This works for me:
if(Build.VERSION.SDK_INT >= 9){
deviceID = android.os.Build.SERIAL;
}
Use Build.VERSION.SDK_INT instead of Integer.parseInt(android.os.Build.VERSION.SDK) then check it by numbers like Build.VERSION.SDK_INT>9

WebDav library Sardine on Android with httpclientandroidlib

Referencing to this thread Using webdav on Android
It is possible to use the Sardine lib ( http://code.google.com/p/sardine/) in combination with the httpclientandroidlib ( http://code.google.com/p/httpclientandroidlib/).
But I keep getting a java.lang.VerifyError Exception.
I tried to reference the Sardine lib as a jar file and as Eclipse-project but its always the same.
If i read the Messages from dalvikVM, before the exeption is thrown, there are problems with javax.xml.bind.JAXBContext.newInstance(). But i cant add the JAXB library or source to to the project because I get several Dx Errors:
[2011-10-28 16:48:40 - FireTablet] Dx 1 error; aborting
[2011-10-28 16:48:40 - FireTablet] Conversion to Dalvik format failed with error 1
[2011-10-28 16:49:00 - FireTablet] Dx
trouble processing "javax/xml/bind/PrintConversionEvent.class":
So this cant be the solution. Does anyone know how to run the sardine library on android?
I am very grateful for help!
Exceptions:
10-28 16:21:33.602: I/Process(22992): Sending signal. PID: 22992 SIG: 9
10-28 16:30:59.005: I/dalvikvm(23056): Could not find method javax.xml.bind.JAXBContext.newInstance, referenced from method com.googlecode.sardine.util.SardineUtil.<clinit>
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to resolve static method 20578: Ljavax/xml/bind/JAXBContext;.newInstance ([Ljava/lang/Class;)Ljavax/xml/bind/JAXBContext;
10-28 16:30:59.005: D/dalvikvm(23056): VFY: replacing opcode 0x71 at 0x000a
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to resolve exception class 2678 (Ljavax/xml/bind/JAXBException;)
10-28 16:30:59.005: W/dalvikvm(23056): VFY: unable to find exception handler at addr 0x50
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejected Lcom/googlecode/sardine/util/SardineUtil;.<clinit> ()V
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejecting opcode 0x0d at 0x0050
10-28 16:30:59.005: W/dalvikvm(23056): VFY: rejected Lcom/googlecode/sardine/util/SardineUtil;.<clinit> ()V
10-28 16:30:59.005: W/dalvikvm(23056): Verifier rejected class Lcom/googlecode/sardine/util/SardineUtil;
10-28 16:30:59.005: D/AndroidRuntime(23056): Shutting down VM
10-28 16:30:59.005: W/dalvikvm(23056): threadid=1: thread exiting with uncaught exception (group=0x40015578)
10-28 16:30:59.009: E/AndroidRuntime(23056): FATAL EXCEPTION: main
10-28 16:30:59.009: E/AndroidRuntime(23056): java.lang.VerifyError: com.googlecode.sardine.util.SardineUtil
10-28 16:30:59.009: E/AndroidRuntime(23056): at com.googlecode.sardine.impl.SardineImpl.list(SardineImpl.java:339)
10-28 16:30:59.009: E/AndroidRuntime(23056): at hsr.ifs.firetablet.network.WebDavConnector.getFacilityNames(WebDavConnector.java:36)
I use Android API-Level 10 & Java 1.6.
Not sure what's going on, but did you try https://github.com/yeonsh/Sardine-Android ?
I also had the same issue and modified the Sardine project to use SimpleXml instead of JAXB. Here is my version of the library: https://github.com/thegrizzlylabs/sardine-android

libs suddenly won't load in dynamic linker (NDK)

I've been developing an NDK app for quite some time and it's been working well. However, today the app randomly decided to not start anymore, after I compiled it after making some nominal change. It's caused by a cryptic problem with loading the app's main library. Here's some log output:
08-11 18:38:11.220 D/dalvikvm( 1237): Added shared lib /mnt/asec/com.audia.rta-1/lib/libqtandroid.so 0x40513bd8
08-11 18:38:11.220 D/dalvikvm( 1237): No JNI_OnLoad found in /mnt/asec/com.audia.rta-1/lib/libqtandroid.so 0x40513bd8, skipping init
08-11 18:38:11.220 D/dalvikvm( 1237): Trying to load lib /mnt/asec/com.audia.rta-1/lib/librta.so 0x40513bd8
08-11 18:38:11.260 D/AndroidRuntime( 1237): Shutting down VM
08-11 18:38:11.260 W/dalvikvm( 1237): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-11 18:38:11.260 E/AndroidRuntime( 1237): FATAL EXCEPTION: main
08-11 18:38:11.260 E/AndroidRuntime( 1237): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]: 67 cannot locate '_ZNSaIcEC1Ev'...
08-11 18:38:11.260 E/AndroidRuntime( 1237):
08-11 18:38:11.260 E/AndroidRuntime( 1237): at java.lang.Runtime.loadLibrary(Runtime.java:434)
08-11 18:38:11.260 E/AndroidRuntime( 1237): at java.lang.System.loadLibrary(System.java:554)
08-11 18:38:11.260 E/AndroidRuntime( 1237): at com.audia.rta.RTA.onCreate(RTA.java:139)
According to some Google results, _ZNSaIcEC1Ev is part of libstdc++. I've checked, and it gets linked in the build process, and g++ is being used for linking.
Oddly enough, reverting to an older apk of the app fixes the problem, but compiling an old revision and installing that doesn't fix the problem. Everything in my build system is checked into version control, and I've done several clean builds. All my builds were working today and then they just stopped working. I didn't upgrade or install anything; it happened while I was in the middle of testing new code. What happened?
Update: Building from a freshly checked out copy doesn't fix the problem.
Update 2: Is there any way I can track down the link to that symbol, maybe with objdump? Maybe this could provide some clues.
I ended up compiling everything with a fresh NDK install, and it worked. It's as if the old one was corrupted somehow, though I have no idea how.
It was also an upgrade from r5b to r6, so maybe it's related to the NDK version.

Categories

Resources