android - 如何制作同时支持 32 位和 64 位架构的 Android 应用程序?

标签 android android-ndk google-play 64-bit 32-bit

我刚刚收到并阅读了a newsletter from Google Play提到从明年开始,商店“将要求新的应用程序和带有 native 库的应用程序更新提供 32 位版本之外的 64 位版本”。

对于尚未阅读的人,它指出:

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.

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

最佳答案

根据 Google Play 团队发送的官方电子邮件,需要采取的措施是:

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.

所以,链接的文档说明:

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.[...]

而且,要构建 64 位库,您基本上需要遵循以下说明:

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'
// ...

最后,一个简短的说明:

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

顺便说一句,this official video稍微谈一下。

关于android - 如何制作同时支持 32 位和 64 位架构的 Android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48549563/

相关文章:

java - Android 在 2.1 及更低版本中将位图传递给 native

android - 如何添加这个谷歌播放更新对话框?

android - 我的应用程序显示 "This item is not compatible with your device"

javascript - 每天在 5 :00 AM using firebase javascript 清除 firebase 数据库值

Android SQLite 条件在轮类期间失败更改

android - 如何在 AAR 文件中将 ndk-stack 与共享库一起使用

android - 在 Android 中通过共享库显示所有导出函数的代码

android - 如何使用 Java 8 在 Android 和桌面(IntelliJ 2018 CE/Gradle)上使用 libGDX 进行开发

java - 来自 jsonobject 的 getstring 的 settext 显示 ' 而不是 '

Android - "Application not installed"- 无法使用新的 apk 更新 - React Native