如何制作同时支持 32 位和 64 位架构的 Android 应用程序? [英] How to make Android apps which support both 32-bit and 64-bit architecture?

查看:93
本文介绍了如何制作同时支持 32 位和 64 位架构的 Android 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚收到并阅读了a来自 Google Play 的时事通讯 提到从明年开始,商店将要求新的应用程序和带有本机库的应用程序更新除了提供 32 位版本之外还提供 64 位版本".

对于那些还没有阅读过的人,它指出:

<块引用>

2019 年的 64 位支持要求

Android 中引入了对 64 位架构的平台支持5.0.如今,超过 40% 的上线 Android 设备支持 64 位,同时仍保持 32 位兼容性.对于应用程序使用本机库,64 位代码通常提供显着的更好的性能,增加了寄存器和新指令.

期待未来支持 64 位代码的 Android 设备只是,Play Console 将要求新应用和应用更新本机库除了提供 32 位版本外,还提供 64 位版本版本.这可以在单个 APK 中或作为多个 APK 之一已发布 APK.

我们不会移除 32 位支持.Google Play 将继续支持 32 位应用程序和设备.不包含本机代码的应用不受影响.

此更改将于 2019 年 8 月生效.我们提供今天提前通知,以便为不这样做的开发人员留出充足的时间还支持 64 位来规划过渡.继续关注未来在这篇文章中,我们将深入研究性能优势Android 上的 64 位本机库,并查看 CPU 和NDK 架构指南,了解更多信息.

我们需要进行哪些实际更改才能在适用时完全符合这一新要求?

解决方案

根据 Google Play Team 发送的官方邮件,需要的操作是:

<块引用>

如果您还没有,我们鼓励您开始为 64 位工作尽快提出要求.许多应用程序完全用非本地代码(例如 Java 编程语言或 Kotlin)和不需要更改代码.

请注意,我们不会更改我们的 32 位政策支持.Google Play 将继续提供 32 位原生应用代码到 32 位设备.该要求意味着这些应用程序将还需要有 64 位版本.

为了帮助您完成转换,我们准备了文档 关于如何检查您的应用程序是否已经支持 64 位以及如何成为64 位兼容.

我们还在下方提供了一个高级别的时间表.

因此,链接的文档解释了:

<块引用>

如果您的应用仅使用以 Java 编程语言编写的代码,或者Kotlin,包括任何库或 SDK,您的应用程序已经准备好64 位设备.如果您的应用程序使用任何本机代码,或者您不确定确实如此,您需要评估您的应用并采取行动.

[...]

检查 64 位库的最简单方法是检查APK 文件的结构.构建后,APK 将打包应用程序所需的任何本机库.本机库存储在基于 ABI 的各种文件夹.不需要支持每一个64 位架构,但对于每个原生 32 位架构,您支持您必须包含相应的 64 位架构.

对于 ARM 架构,32 位库位于armeabi-v7a.64 位等效项是 arm64-v8a.

对于 x86 架构,寻找 x86 为 32 位和 x86_64 为64 位.

首先要做的是确保您在这两个版本中都有本机库这些文件夹中.[...]

而且,要构建 64 位库,您基本上需要按照以下说明进行操作:

<块引用>

大多数 Android Studio 项目使用 Gradle 作为底层构建系统,因此本节适用于这两种情况.启用构建您的本机代码就像添加 arm64-v8a 和/或 x86_64 一样简单,根据您希望支持的架构,应用程序的build.gradle"文件中的 ndk.abiFilters 设置:

//你的应用的 build.gradle应用插件:'com.android.app'安卓 {compileSdkVersion 27默认配置{appId "com.google.example.64bit"minSdk 版本 15目标SDK版本28版本代码 1版本名称1.0"ndk.abiFilters 'armeabi-v7a'、'arm64-v8a'、'x86'、'x86_64'//...

最后,请注意:

<块引用>

您的应用的 64 位版本应该提供相同的质量和功能设置为 32 位版本.

顺便说一下,这个官方视频对此进行了一些讨论.>

I've just received and read a newsletter from Google Play mentioning that from next year on, the store "will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions".

For those who haven't read it yet, it states:

64-bit support requirement in 2019

Platform support for 64-bit architectures was introduced in Android 5.0. Today, over 40% of Android devices coming online have 64-bit support, while still maintaining 32-bit compatibility. For apps that use native libraries, 64-bit code typically offers significantly better performance, with additional registers and new instructions.

In anticipation of future Android devices that support 64-bit code only, the Play Console will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions. This can be within a single APK or as one of the multiple APKs published.

We are not removing 32-bit support. Google Play will continue to support 32-bit apps and devices. Apps that do not include native code are unaffected.

This change will come into effect in August 2019. We're providing advance notice today to allow plenty of time for developers who don't yet support 64-bit to plan the transition. Stay tuned for a future post in which we'll take an in-depth look at the performance benefits of 64-bit native libraries on Android, and check out the CPUs and Architectures guide of the NDK for more info.

What practical changes will we need to make to perfectly comply with this new requirement when applicable?

解决方案

According to an official email sent by the Google Play Team, the action required is:

If you haven't yet, we encourage you to begin work for the 64-bit requirement as soon as possible. Many apps are written entirely in non-native code (e.g. the Java programming language or Kotlin) and will not need code changes.

Please note that we are not making changes to our policy on 32-bit support. Google Play will continue to deliver apps with 32-bit native code to 32-bit devices. The requirement means that those apps will need to have a 64-bit version as well.

To help you make the transition, we've prepared documentation on how to check whether your app already supports 64-bit and how to become 64-bit compliant.

We're also providing a high-level timeline below.

So, the linked documentation explains:

If your app uses only code written in the Java programming language or Kotlin, including any libraries or SDKs, your app is already ready for 64-bit devices. If your app uses any native code, or you are unsure if it does, you will need to assess your app and take action.

[...]

The simplest way to check for 64-bit libraries is to inspect the structure of your APK file. When built, the APK will be packaged with any native libraries needed by the app. Native libraries are stored in various folders based on the ABI. It is not required to support every 64-bit architecture, but for each native 32-bit architecture you support you must include the corresponding 64-bit architecture.

For the ARM architecture, the 32-bit libraries are located in armeabi-v7a. The 64-bit equivalent is arm64-v8a.

For the x86 architecture, look for x86 for 32-bit and x86_64 for 64-bit.

The first thing to do is ensure that you have native libraries in both of these folders.[...]

And, to build 64-bit libraries, you basically need to follow the instructions below:

Most Android Studio projects use Gradle as the underlying build system, so this section applies to both cases. Enabling builds for your native code is as simple as adding the arm64-v8a and/or x86_64, depending on the architecture(s) you wish to support, to the ndk.abiFilters setting in your app's 'build.gradle' file:

// Your app's build.gradle
apply plugin: 'com.android.app'

android {
   compileSdkVersion 27
   defaultConfig {
       appId "com.google.example.64bit"
       minSdkVersion 15
       targetSdkVersion 28
       versionCode 1
       versionName "1.0"
       ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
// ...

Finally, a quick note:

The 64-bit version of your app should offer the same quality and feature set as the 32-bit version.

By the way, this official video talks a little bit about it.

这篇关于如何制作同时支持 32 位和 64 位架构的 Android 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆