dalvik

Unified stack for native and Java in Android Runtime (ART)

放肆的年华 提交于 2019-12-06 07:26:11
https://developer.android.com/guide/practices/verifying-apps-art.html#Stack_Size This document says that the ART has a unified stack for native and Java. Could you tell me what does it mean? I understand that thread's stack-size can be defined only when it is created, e.g. using constructor of Thread class in Java code or pthread API in native code. So I can not understand how does unified stack affect behavior of applications. Please direct me to some good tutorials or snippet throws StackOverflowError resulted from unified stack. In Dalvik, each thread have a two separate stacks, one for the

Mockito on Android emulator

浪子不回头ぞ 提交于 2019-12-06 06:11:20
问题 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:

龙芯通过指令系统二进制翻译运行视窗系统(windows)

旧城冷巷雨未停 提交于 2019-12-06 03:32:40
文章转帖自《电子发烧友》网站。   发展以CPU 和操作系统为核心的自主软硬件已经成为中国的国家战略。 经过自“十五” 以来的十余年努力, 以“龙芯”、“飞腾”、“申威” 为代表的中国自主CPU 研发取得了长足的进展, 部分设计技术达到了世界先进水平, 并在实际应用方面取得了若干突破, 出现了良好的发展势头。 随着自主CPU应用和产业化的不断深入, 相关的软硬件生态问题变得越来越突出。 虽然自主CPU 都在不同程度上采取了与国外CPU 兼容的技术路线, 如“龙芯” 在取得MIPS 架构授权的基础上采取与MIPS 兼容的策略, 但比起主流的软硬件生态, 如X86 在桌面/服务器领域的软件生态以及ARM 在手持终端领域的软件生态, 自主CPU 在软硬件生态方面还处在很初级的水平, 严重制约了自主CPU 的产业化。   二进制翻译技术是实现跨指令系统兼容的重要手段。 二进制翻译技术在宿主机(host) 上用软件模拟出一个目标机/客户机(guest) 指令系统兼容的CPU 来, 从而在宿主机上执行客户机的二进制代码, 达到兼容的目的。 如在MIPS 计算机上模拟X86 指令系统, 从而实现与X86 兼容。 二进制翻译的最大问题是效率问题, 用软件模拟的CPU 比硬件直接实现的CPU 慢很多。 如在MIPS 计算机上使用二进制翻译的方法运行X86 二进制程序,

浅谈Android FrameWork框架和它在android的四层架构起到的作用

我们两清 提交于 2019-12-05 23:54:49
这里写一些关于Android Framework比较重要的知识点,这些东西对于之后理解和研究Android Framework有很大好处,就是让我们脑子里先有一个大概的模型,以及认识一点之后经常会碰见的角色。 首先贴一张图,刚学安卓的时候看书籍或者看视频教程的时候通常第一篇就会祭出这张图,但是当时你可能就是一瞥而过,毕竟初学时一般只关心应用层功能的实现啊,或者如何布局啊这些,现在来复习一下这张很重要的图: 图上分的很清楚,分为四层,分别为: 1.应用程序层 这一层一般我们最为熟悉了,我们平常开发安卓用java编写的app都属于这一层,当然系统自带的程序比如时钟啊,email等都是属于这一层 2.应用程序框架层(Framework) 这一层是核心应用程序所使用的API框架,为应用层提供各种接口API,包括各种组件和服务来支持我们的安卓开发,包括ActivityManager,WindowManager,ViewSystem等我们讲到AndroidFramework时很经常要提到的东西。 3.系统运行库层 从图上就可以看出,这一层有两部分: 一.程序库 Android 包含一些C/C++库,这些库能被Android系统中不同的组件使用。它们通过 Android 应用程序框架为开发者提供服务。以下是一些核心库: 系统 C 库 - 一个从 BSD 继承来的标准 C 系统函数库( libc

Android recommended way of safely supporting newer apis has error if the class implements a newer interface. Why?

╄→гoц情女王★ 提交于 2019-12-05 23:38:40
In order to support different Api Levels, I am using the technique described here: http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html Here is the example from the article: public static VersionedGestureDetector newInstance(Context context, OnGestureListener listener) { final int sdkVersion = Integer.parseInt(Build.VERSION.SDK); VersionedGestureDetector detector = null; if (sdkVersion < Build.VERSION_CODES.ECLAIR) { detector = new CupcakeDetector(); } else if (sdkVersion < Build.VERSION_CODES.FROYO) { detector = new EclairDetector(); } else { detector =

Is it necessary to keep classes of the same package in the same dex while using multiple dex files

六月ゝ 毕业季﹏ 提交于 2019-12-05 16:46:53
About the Title "classes of the same package" means classes that share the same package access. Please pay attention to the fact that class a.b.c.Foo doesn't have package access to class a.b.Bar . Because the latter can't access to the former if the former's modifier is default. Problem If I split two classes in the same packages into two dex files, even though I load them correctly, I will also get some error while running, the logcat likes: I/dalvikvm( 6498): DexOpt: illegal method access (call Lcom/fish47/multidex/Foo;.isWholeWord (Lcom/fish47/multidex/Foo;)Z from Lcom/fish47/multidex

Native crash on an Android-Java based app?

独自空忆成欢 提交于 2019-12-05 14:43:58
Background My app has 100% code written in Java, it doesn't need to make any heavy operations. The app itself uses only the next libraries, yet non of them have JNI code: ActionBarSherlock google-play-services_lib The problem Today I got a weird crash report, which doesn't show any normal exception information . The report was sent via a "Galaxy S5 (klte)" device, with Android 4.4 . Here's the crash report title: Native crash at /dev/ashmem/dalvik-jit-code-cache in /dev/ashmem/dalvik-jit-code-cache (deleted) And here is the crash content : *** *** *** *** *** *** *** *** *** *** *** *** *** **

Disadvantages in Multidexing the android application

你说的曾经没有我的故事 提交于 2019-12-05 12:27:37
问题 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

How to debug “com.android.okhttp”

£可爱£侵袭症+ 提交于 2019-12-05 12:15:55
问题 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

Android ClassLoader 解析

一个人想着一个人 提交于 2019-12-05 11:31:29
类加载器 前言 Android的Dalvik/ART虚拟机如同标准JAVA的JVM虚拟机一样,在运行程序时首先需要将对应的类加载到内存中。因此,我们可以利用这一点,在程序运行时手动加载Class,从而达到代码动态加载可执行文件的目的。Dalvik/ART虚拟机虽然与JVM虚拟机不一样,ClassLoader具体的加载细节不一样,但是工作机制是类似的,也就是说在Android中同样可以采用类似的动态加载插件的功能. ClassLoader分类 下面我们简单写一个Demo来看下ClassLoader有哪些 源码如下: package org.professor.classloaderdemo; import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { @ Override protected void onCreate(Bundle savedInstanceState) { super.onCreate