简体   繁体   English

Android 市场多款APK……不同的CPU架构怎么样?

[英]Android Market multiple APK… How about different CPU architectures?

So I thought I could now upload my app using different NDK compiled libraries for targeted CPU architectures but it seems like that's not possible.所以我想我现在可以使用针对目标 CPU 架构的不同 NDK 编译库上传我的应用程序,但这似乎是不可能的。

Anyone know how to upload to the Android Market different APKs each containing libraries compiled specifically for different CPU architectures?任何人都知道如何将不同的 APK 上传到 Android 市场,每个 APK 都包含专门为不同 CPU 架构编译的库?

I haven't tried this and seems like a waist of space, but can we include multiple compiled libraries in one APK?我还没有尝试过,看起来有点空间,但是我们可以在一个 APK 中包含多个编译库吗?

Update:更新:
Apparently when the user installs the apk the unsupported libraries will not be installed on the device.显然,当用户安装 apk 时,设备上不会安装不受支持的库。 This is good but the user still has to download the entire apk wasting bandwidth.这很好,但用户仍然必须下载整个 apk 浪费带宽。

Well, finally Google Play allows to have Multi-apk targeting !好吧,最后 Google Play 允许有Multi-apk 定位

"We have added new functionality for apps that use multiple APK support. You can now target each APK to a specific native platform." “我们为使用多个 APK 支持的应用添加了新功能。您现在可以将每个 APK 定位到特定的原生平台。”

Unless you have a bunch of code for your app, I would suggest just putting the native code for the three architectures that android supports and the moment, armv5, armv7, and x86.除非您的应用程序有一堆代码,否则我建议您只为 android 支持的三种架构以及 armv5、armv7 和 x86 提供本机代码。 It willl triple the size of the code portion of your apk, but 3*(a small number) is still a small number.它将使您的 apk 代码部分的大小增加三倍,但 3*(一个小数字)仍然是一个小数字。 You can do this by modifying your jni/Application.mk file, or creating it if you don't already have it, and add the line:您可以通过修改 jni/Application.mk 文件来完成此操作,或者如果您还没有它,则创建它,然后添加以下行:

APP_ABI := armeabi armeabi-v7a x86

This will compile for all three.这将为所有三个编译。

Note though that there's a bug with the current ndk (ndk r6), that tries to link the x86 code to the arm code.请注意,当前 ndk (ndk r6) 存在一个错误,它试图将 x86 代码链接到 arm 代码。 This is fixed if you get the AOSP project, source.android.com, or you can just wait until google releases r6b, which will likely have the fix.如果您获得 AOSP 项目 source.android.com,则此问题已修复,或者您可以等到 google 发布 r6b,这可能会有修复。 Otherwise, if you you don't want to do that, you can just leave off the x86 portion of the line for now, and release your app without x86 code in it, and push an update when the new ndk comes out.否则,如果您不想这样做,您可以暂时放弃该行的 x86 部分,并在其中不包含 x86 代码的情况下发布您的应用程序,并在新的 ndk 出现时推送更新。 I'm not aware of many popular devices that use x86 instructions yet.我还不知道有很多流行的设备使用 x86 指令。

Please see Multiple APK Support in the Android documentation.请参阅 Android 文档中的多 APK 支持 This details some of the specifics of releasing multiple APKs of the same product/application.这详细说明了发布同一产品/应用程序的多个 APK 的一些细节。

As for the NDK specifics, and as already mentioned, you can utilize multiple platforms / ABIs in the APP_ABI value of your Android.mk.至于 NDK 细节,如前所述,您可以在 Android.mk 的 APP_ABI 值中使用多个平台/ABI。

In new Play store developer console if you want to add multiple APK than you must need to use same package name and same keystore key but different version code.在新的 Play 商店开发者控制台中,如果要添加多个 APK,则必须使用相同的 package 名称和相同的密钥库密钥,但版本代码不同。 You have publish app then first upload Apk eg mobile_release and rollout for production, after when you upload another apk, you should choose option RETAIN on previous APK also with current APK.您已经发布了应用程序,然后首先上传 Apk 例如 mobile_release 并推出生产,当您上传另一个 apk 后,您应该在以前的 APK 上选择选项 RETAIN 也与当前的 APK。

  android {

        // To create different apk per abi
        splits {
            abi {
                enable true
                reset()
                include 'armeabi', 'armeabi-v7a', 'x86'
                universalApk true
            }
        }
    }

    import com.android.build.OutputFile

    // Map for the version code
    ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'x86': 3]
    android.applicationVariants.all { variant ->

        // assign different version code for each output
        variant.outputs.each { output ->
            int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
            output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode
        }
    }

You can declare supports-gl-texture in your AndroidManifest.xml for each separately compiled (and re-packaged) app.您可以在AndroidManifest.xml中为每个单独编译(并重新打包)的应用程序声明supports-gl-texture This will provide Market filtering, so a single user will only see one version of your app.这将提供市场过滤,因此单个用户只能看到您应用的一个版本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM