简体   繁体   English

Android APK编译为ART运行时和dalvik运行时

[英]Android apk compile to ART runtime and dalvik runtime

Google added a new ART runtime with Android 4.4. Google在Android 4.4中添加了新的ART运行时。 How can I target my apk to both ART runtime and Dalvik runtime? 如何将我的APK定位到ART运行时和Dalvik运行时?

This change is without consequences for the developers. 此更改对开发人员没有影响。 Your app remains exactly the same, nothing to do there. 您的应用程序保持完全相同,无所事事。 Just make sure you target API 19 so that your app is available for KitKat users. 只需确保您以API 19为目标即可,以便KitKat用户可以使用您的应用。 They will decide in their phone if they want to use ART or Dalvik. 他们将在手机中决定是否要使用ART或Dalvik。

This is an old question now, but very key. 现在这是一个老问题,但非常关键。 I confirmed today, all my apps break with ART+Android-5 on Nexus-x tablets. 我今天确认,我所有的应用都在Nexus-x平板电脑上使用ART + Android-5破解。 ART does more strict JNI checks, so if your app uses java plus native code,the move from Dalvik to ART may break app operation. ART会执行更严格的JNI检查,因此,如果您的应用程序使用Java加本地代码,那么从Dalvik迁移到ART可能会中断应用程序的运行。 For me, it has been a complete show-stop. 对我来说,这是一个完整的表演。 I have 6 apps in Google Store and all fail now on Nexus devices running Android 5.x, yet they run correctly on all 4.xx (Kitkat) series devices. 我在Google Store中有6个应用程序,但现在所有这些应用程序都在运行Android 5.x的Nexus设备上失败,但是它们在所有4.xx(Kitkat)系列设备上都能正常运行。 This is most frustrating. 这是最令人沮丧的。 I am going thru all the ART/ Dalvik questions and answers on this site. 我将浏览该网站上所有的ART / Dalvik问题和答案。 ART and Android-5.x is very significant change, so the question asked here "How do I target my apk to both Dalvik and ART?" ART和Android-5.x是非常重大的变化,因此这里的问题是“我如何将我的apk定位到Dalvik和ART?” is a key and very critical question. 是一个关键且非常关键的问题。 Time has proven that the responses given suggesting "No difference to developers" is manifestly incorrect. 时间已经证明,给出的建议“对开发人员没有区别”的回答显然是错误的。 It certainly is in our case. 当然,就我们而言。

Two specific issues are documented, and I quote from "Verifying App Behavior on the Android Runtime (ART)": 记录了两个特定的问题,我引用“在Android运行时(ART)上验证应用行为”的内容:

1) " Checking JNI code for garbage-collection issues ART has a compacting garbage collector under development on the Android Open Source Project (AOSP). Once the compacting garbage collector is in use, objects may be moved in memory. If you use C/C++ code, do not perform operations that are incompatible with compacting GC. We have enhanced CheckJNI to identify some potential issues (as described in JNI Local Reference Changes in ICS)." 1)“正在检查JNI代码是否存在垃圾回收问题ART在Android开源项目(AOSP)上正在开发压缩垃圾回收器。一旦使用压缩垃圾回收器,对象可能会移动到内存中。如果使用C / C ++代码不会执行与压缩GC不兼容的操作。我们对CheckJNI进行了增强,以识别某些潜在问题(如ICS中的JNI本地参考更改所述)。” In other words, the new ART memory mangement model may break your existing (and operational) native code. 换句话说,新的ART内存管理模型可能会破坏您现有的(和可操作的)本机代码。

2) " Error handling ART's JNI throws errors in a number of cases where Dalvik didn't.". 2)“错误处理ART的JNI在Dalvik没有的许多情况下会引发错误。”。

A limited explanation of some of the issues that will cause errors to be thrown by the Android 5.x ART is provided in: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 以下内容提供了对某些会导致Android 5.x ART引发错误的问题的有限解释: http : //developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues

The forward-compatibility solution currently being adopted among users of Android devices running ART and 5.x, and facing non-operational apps, is a downgrade to Android 4.4.4, by unlocking the bootloader, wiping the device memory, and installing system image "Hammerhead", in the case of those running Nexus series tablets. 通过解锁引导加载程序,擦除设备内存并安装系统映像,当前正在运行ART和5.x且面向非运行应用的Android设备的用户中采用的前向兼容性解决方案已降级为Android 4.4.4。如果是运行Nexus系列平板电脑的用户,则为“锤头”。 For Samsung tablets, a tutorial is available at: http://forums.androidcentral.com/samsung-galaxy-s5/489071-tutorial-downgrade-samsung-galaxy-s5-5-0-4-4-kitkat.html 对于Samsung平板电脑,可以在以下位置获得教程: http : //forums.androidcentral.com/samsung-galaxy-s5/489071-tutorial-downgrade-samsung-galaxy-s5-5-0-4-4-kitkat.html

The dalvik or ART is only the runtime in the Android. dalvikART只是Android中的运行时 As an app developer, you don't have to care about these differences. 作为应用程序开发人员,您不必关心这些差异。 All you have to care about is your app's API level which is describing the dependence of the Android OS version. 您只需关心应用程序的API级别,即可描述Android OS版本的依赖性。

And in Android 4.4, ART is only a development which is NOT the default runtime even if the release note describing that ART will make app use less memory and run quickly. 而在Android 4.4系统, 技术只是一个发展这是不是默认的运行时,即使发行说明中描述了ART将使应用程序使用较少的内存和快速运行。 If you want to find the different, you can wait for the next version of Android. 如果要查找其他版本,可以等待下一个Android版本。 In the opensource, I found the ART has been setting the default runtime selection. 在开源中,我发现ART一直在设置默认的运行时选择。

For most apps ART will work just fine. 对于大多数应用程序,ART都可以正常工作。

It is, however, not 100% compatible as something that work on Dalvik may not work on ART 但是,它不是100%兼容的,因为在Dalvik上运行的某些功能可能在ART上不起作用

Please visit this link for more information. 请访问此链接以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android ART 运行时是否具有与 Dalvik 相同的方法限制限制? - Does the Android ART runtime have the same method limit limitations as Dalvik? 如何检测Android运行时(Dalvik或ART)? - How can I detect the Android runtime (Dalvik or ART)? 如何在Xamarin中检测Android运行时(Dalvik或ART) - How can I detect the Android runtime (Dalvik or ART) in Xamarin 如何从源代码编译 Android 运行时 (ART) - How to compile the Android runtime (ART) from source Android Runtime(ART或Dalvik)是否包含Java VM堆栈或JVM等本机方法堆栈? - Does Android Runtime(ART or Dalvik) contain Java VM stack or Native Method Stack like JVM? Android ART是否像Dalvik一样支持运行时动态类加载? - Does Android ART support runtime dynamic class loading just like Dalvik? 新的Android运行时(ART)是否仅编译Java代码AOT? - Does the new Android Runtime (ART) compile only Java code AOT? Android Runtime(ART)是虚拟机吗? - Android Runtime(ART) is virtual machine? 是否可以像 Dalvik 一样在 Android Runtime 中运行没有 apk 的 classes.dex? - Is it possible to run classes.dex without apk in Android Runtime like Dalvik? 使用Art代替Dalvik进行编译 - Using Art instead of Dalvik to compile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM