dalvik

Mockito on Android emulator

时间秒杀一切 提交于 2019-12-04 10:44:26
Android newbie here trying to use my favorite Java testing tools in Android. I am attempting to use Mockito 1.9.5 as outlined in the following blog post but cannot get the tests to run on my emulator (I currently do not have a physical device to test with either). Mockit-Android Tutorial: http://www.paulbutcher.com/2012/05/mockito-on-android-step-by-step/ I am able to execute all my normal Junit tests without issue however any of the tests I have leveraged Mockito for I receive the following: Can't open dex cache '/data/dalvik-cache/data@data@com.trendium.peg@cache@Generated-621101.jar@classes

Conversion to Dalvik format failed with error 1 with a scary message in the Console view

江枫思渺然 提交于 2019-12-04 10:22:07
问题 I've seen a few questions with this topic, but when I search for the other part I have in my error, I don't find anything, so I decided to post a question with the full explanation. No errors are recognized in my code. Nowhere. All libraries are added, external library projects are successfully linked. There is no indication that anything should go wrong with a launch. Yet, when I launch the application - Run, compile and build (automatically) - I get a pop up message stating that my project

Android NDK: Dalvik Heap and Native Heap - How Separate Between the two

风流意气都作罢 提交于 2019-12-04 08:23:16
问题 I know there's Dalvik(JVM) heap and Native heap in an android platform. And the Dalvik GC has no work on native heap. But I'm not sure how this work, I mean how the Android OS separate them? possible situation 1: composed by separate memory hardware (I don't believe much) possible situation 2: Android OS has FIXED amount of memory for both heap possible situation 3: Android OS has to allocate part of Dalvik memory heap to become native heap when necessary, and so the size of native heap and

JVM中的OopMap

梦想与她 提交于 2019-12-04 06:45:53
调用栈里的引用类型数据是GC的根集合(root set)的重要组成部分;找出栈上的引用是GC的根枚举(root enumeration)中不可或缺的一环。 JVM选择用什么方式会影响到GC的实现: 如果JVM选择不记录任何这种类型的数据,那么它就无法区分内存里某个位置上的数据到底应该解读为引用类型还是整型还是别的什么。这种条件下,实现出来的GC就会是“保守式GC(conservative GC)”。在进行GC的时候,JVM开始从一些已知位置(例如说JVM栈)开始扫描内存,扫描的时候每看到一个数字就看看它“像不像是一个指向GC堆中的指针”。这里会涉及上下边界检查(GC堆的上下界是已知的)、对齐检查(通常分配空间的时候会有对齐要求,假如说是4字节对齐,那么不能被4整除的数字就肯定不是指针),之类的。然后递归的这么扫描出去。 保守式GC的好处是相对来说实现简单些,而且可以方便的用在对GC没有特别支持的编程语言里提供自动内存管理功能。Boehm-Demers-Weiser GC是保守式GC中的典型代表,可以嵌入到C或C++等语言写的程序中。 小历史故事: 微软的JScript和早期版VBScript也是用保守式GC的;微软的JVM也是。VBScript后来改回用引用计数了。而微软JVM的后代,也就是.NET里的CLR,则改用了完全准确式GC。 为了赶上在一个会议上发布消息

Eclipse stepping into class in android

放肆的年华 提交于 2019-12-04 04:54:16
I have a simple android project that I am trying to debug inside of Eclipse. When I run it in debug mode and use the "Step Over" button, it frequently seems to want to go into Android code (I don't want it to do this, just as a C debugger will not go into libc). I get a screen that comes up which looks similar to: Class File Editor Source not found: The JAR file blahblah/android.jar has no source attachment. You can attach the source by clicking attach source I don't want it to go into Android or Dalvik code at all (even if I could install source code) I am only interested in my own personal

How to debug “com.android.okhttp”

点点圈 提交于 2019-12-03 23:53:57
In android kitkat, URLConnection's implementation has been replaced by OkHttp,How can it debug it? The OkHttp is in this directory: external/okhttp/android/main/java/com/squareup/okhttp When i call the UrlInstance.openConnection().getClass().getName() , it present com.android.okhttp.internal.http.HttpURLConnectionImpl How can i debug the it ? It seems that i can't associate the /android/main/java/com/squareup/okhttp/* to the com.android.okhttp.* When the code excute to the return streamHandler.openConnection(this); /** * Returns a new connection to the resource referred to by this URL. * *

Disadvantages in Multidexing the android application

南笙酒味 提交于 2019-12-03 22:25:21
Recently I have read about the Dalvik 65K method limit. I have understood that the method invocation list can only invoke first 65536 method references. To tackle this we have number of solutions. One of which being multidexing where we split the .dex files to number of classes [classes.dex, classes1.dex ...] by using android's support library. What I have failed to understand is, what drawback does an android application suffer due to this multidexing and why should we put lots of effort in minimising the number of referenced methods. Basically in my understanding, to reduce the method count

Efficient loop through Java List

依然范特西╮ 提交于 2019-12-03 16:55:43
问题 The following list is from the google I/O talk in 2008 called "Dalvik Virtual Machine Internals" its a list of ways to loop over a set of objects in order from most to least efficient: (1) for (int i = initializer; i >=0; i--) //hard to loop backwards (2) int limit = calculate_limit(); for (int i= 0; i< limit; i++) (3) Type[] array = get_array(); for (Type obj : array) (4) for (int i =0; i< array.length; i++) //gets array.length everytime (5) for (int i=0; i < this.var; i++) //has to

Show Complex Toast From BroadcastReceiver

我的未来我决定 提交于 2019-12-03 15:42:31
I wonder if someone can help me. I'm trying to display a toast element when an SMS is received. This toast should contain a layout which has an image (SMS Icon) and 2 textviews (sender, message) If I call the following method from an activity, it works as expected... public void showToast(Context context, String name, String message) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_sms, (ViewGroup) findViewById(R.id.toast_sms_root)); TextView text = (TextView) layout.findViewById(R.id.toastsms_text); text.setText(message); Toast toast = new Toast

Do apps using multiple processes share a Dalvik instance?

我与影子孤独终老i 提交于 2019-12-03 15:27:14
I'm studying Android process management and I'm wondering whether apps using multiple processes (not threads) share a Dalvik instance or there exists a Dalvik instance per process, even for the same app. Could you point me to some official source ( doc, talk, paper etc.)? Thanks No. Dalvik doesn't span processes. However, the Binder IPC mechanism can do a very convincing job of making objects appear to migrate to a different process and its Dalvik instance. Also, the memory management is very good about sharing read-only pages across all processes that need them. The Dalvik process hosting a