I know that there are many questions that have been asked about Android code coverage (I have done some researches before asking here), yet I still get stuck at some points so if you can help, I will appreciate it very much.
What I am doing right now is not really Unit Test but Activity Test to verify the views (check whether they're null or not, check the buttons if they're clickable, counts the number of view in one activity), then I implement some code to test public methods of each activity too and I want to know the code coverage of those tests. First I try EclEmma but it seems like they don't support android so I move to Emma. Then I have a common error as many many people on the Internet:
[exec] android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests:INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalAccessError
[exec] INSTRUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Classref in pre-verified class resolved to unexpected implementation
[exec] INSTRUMENTATION_CODE: 0
[echo] Setting permission to download the coverage file...
[exec] Unable to chmod /data/coverage.ec: No such file or directory
[echo] Downloading coverage file into project directory...
[exec] remote object '/data/coverage.ec' does not exist
I tried many things that other people do but they just can't fix my issues. I changed from data/data/coverage.ec to sdcard/coverage.ec and now is data/coverage.ec, none of them works. I tried to mount -o remount rw /sdcard, that doesn't work too.
Is there any other ways to fix this? Are Activity Tests even test-able? or I have to change to something other than Emma?
My bad, at first I followed a site (I don't remember) to copy emma.jar into my test project /libs/. I think it somehow calls the jar file twice so it throws IllegalAccessError . I solve this problem by deleting all emma, emma_ant jar files and copy them into /Java/jdk/jre/lib/ext. Now all of my tests run fine and I can get the code coverage now.
Related
I'm new to NativeScript and took over a project recently upgraded from NativeScript 4 to 6. Here is my environment detials:
Windows 10
Node v16.6.1
NativeScript 8.0.2
Android Studio 11 (with al
the recommended updates to date)
VS Code 1.58.2
I can create a new Native script project with "tns create" and build/run it in the simulator just fine. However, when I try to run the project the build throws the following error:
java.lang.RuntimeException: Class not found android.support.v4.view.ViewPager.OnPageChangeListener
at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:551)
at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:534)
at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283)
at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171)
at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234)
at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121)
at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97)
at org.nativescript.staticbindinggenerator.Main.main(Main.java:55)
Here is the run command I'm using: "tns run android --emulator"
I have tried tons of things and searches but no luck resolving this issue.
So I had an idea and searched with a different search engine than I normally use. I did find some ideas which helped me resolved the issue.
I had previously searched in VSCode for variations on "android.support.v4.view.ViewPager.OnPageChangeListener", but only found the log file with the error. Then I learned you have to change the filter options of the find in file search otherwise the files you are looking for can be excluded from the search results. I also used Baregrep to confirm I was getting everything.
I fixed the issue by replacing all occurrences of:
android.support.v4.view.ViewPager with androidx.viewpager.widget.ViewPager
Also you may need to install widgets:npm i tns-core-modules-widgets
Since the files where I made the changes were all non-project files (many of them in the node_modules directory) there is probably something else that involves updating Node or NativeScript that may solve this as well.
If someone else figures that out, I'll be watching this thread for updates, and thanks in advance!
Fissh
I am trying to build an android application with OF. The application runs in two other computers. However, it does not work on mine. I am using a mac.
I run the command "make AndroidDebug" in the project folder, and this is the error I have:
/Library/openFrameworks/addons/ofxHTTP/libs/ofxHTTP/src/PostRouteFileHandler.cpp:98:46: error: invalid use of incomplete type 'class Poco::Path'
ss << Poco::Path(formFileName).getExtension();
I have installed poco, but nothing changes afterwards.
What can I do to solve this?
Thanks
Have you included Poco/Path.h?
A forward declaration might appeared earlier (possibly in another header) without complete definition.
I hit this error and found no hits for the error message, so I thought I'd share the solution I came up with to save anyone else facing the problem repeating my work.
When writing a new Android library (apklib) for use in a (large) application, I'm getting the following error during dexing when I add my new project as a dependency:
trouble writing output: Too many field references: 70185; max is 65536.
You may try using --multi-dex option.
References by package:
<...long list of packages with field counts elided...>
The particular build step it fails on is:
java -jar $ANDROID_SDK/build-tools/19.0.3/lib/dx.jar --dex \
--output=$PROJECT_HOME/target/classes.dex \
<... long list of apklib and jar dependencies elided ...>
Using --multi-dex as recommended by the error message might be a solution, but I'm not the owner of the application project and it already has a large complex build process that I would hesitate to change regardless.
I can reproduce this problem with a no-op test library project that has literally no fields, but in the error output it's listed as having 6000+ fields. Of the packages listed in the error output, there are a handful with similar 6k+ field counts, but then the vast majority have more plausible <1k field counts.
This problem is similar to the "Too many methods" problem that Facebook famously hacked their way around. The FB solution seems insane, and the only other solutions I've found (e.g., this Android bug ticket, or this one, this SO answer, this other SO answer) all involve changing the main app's code which is well beyond the scope of what I want to do.
Is there any other solution?
The solution was to change the package in the AndroidManifest to match the main application's package.
A manifest like this:
<manifest package="com.example.testlibrary" ...
resulted in 6k+ fields and build failure. Changing it to match the main application's package
<manifest package="com.example.mainapplication" ...
resulted in the project building successfully.
Note that only the package in the manifest is changing, I did not make any changes to the library's Java source or its layout (the Java package was still com.example.testlibrary with directory structure to match).
I hypothesize that the different package name is causing all the Android fields to be included again under that package. All the packages in the error listing with 6k+ fields had a different package name than the main application.
I also (later, grr), found this blog post which details the same problem and the eventual same solution.
I recently added some .gifs to my /drawable so that I can use them with buttons. This worked fine (no errors). Now, when I go to rebuild/run my application, I get the following error:
Error: Gradle: Execution failed for task ':MyProject:mergeDebugResources'. > Index: 0
I'm not sure how to fix this (and there appears to be no other similar issues that I could find online.
Edit: Now it's the same error, but it also says (at the end of the first error)
Running /Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt failed. See output
Okay, I fixed the issue. It was quite weird.
A) I had some capital letters in my res/drawables folder. Not too weird -- I can see how that would remove the first error.
B) Then, however, a lot of values in my main activity file became undefined. I had to manually import 'com.myapp.R'. Now that was weird.
Fortunately, everything is now working.
I hope that if anyone gets the same errors as me, that this response can help them.
I have an important problem while compiling Android Application.
Using Windev Mobile, it generates java code, compile and create apk, however, when the apk creation, an error happens:
command line: "myjavapath\java.exe" -Xmx1024m -Djava.ext.dirs=.\platform-tools\lib -jar .\platform-tools\lib\dx.jar --dex --output "path\classes.dex" "path\classes" "path\libs"
returned error:
Trouble writing output: No expanded opcode for 0004368d R.java:11#0001: invoke-direct v0:NffffLmynamespace/R$attr;, java.lang.Object.<init>:()v
Furthermore, R$attr in R.java contains nothing:
public static final class attr {
}
I assume there is a hard limit of 64k. But:
The R.java file contains only 364 lines, if these lines are
fields/methods references, I'm very far away from 64k hard limit.
This error happened when I add a specific window, in my Windev Mobile project. Window that I'm using in another project without error.
So, what do you think it comes from?
If you need any information, or document, no problem.
Thanks in advance.
PS: Maybe my english isn't perfect, I sorry for that.
There are various limits in the dex file format. It looks like the one you are encountering is that there can't be more than 64k method references. This limit is for all classes in your dex file, not for just a single class.
The fact that the error is occurring on that class has nothing to do with the class itself, that's just that where it happened to hit the limit.
The only solution currently, is to reduce the size of your code, or to split some classes out into a separate dex file that you load dynamically.