如何为armv8编译本机库?

时间:2018-11-28 07:24:40

标签: android android-studio cmake android-ndk

我正在为四个架构x86,x86_64,armeabi-v7a和arm64-v8a编译拆分apk。该应用程序运行良好,并且可以在大多数设备上加载本机库。但是在某些设备上,发生错误,无法在armv8文件夹或arm文件夹中找到mylibrary.so.。这是我的代码,用于生成拆分的apk和生成不满意的链接错误

splits {
        // Configures multiple APKs based on ABI.
        abi {
            // Enables building multiple APKs per ABI.
            enable true


            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for x86, armeabi-v7a, and mips.
            reset()

            // Specifies a list of ABIs that Gradle should create APKs for.
            include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"

            // Specifies that we want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }



    def abiCodes = ['x86':0, 'x86_64':1, 'armeabi-v7a':2, 'arm64-v8a':3]
    android.applicationVariants.all { variant ->
        // Assigns a different version code for each output APK.
        variant.outputs.each {
            output ->
                def abiName = output.getFilter(OutputFile.ABI)
                output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode
        }
    }

当我分析apk时,成功在arm64-v8a apk中获得了所需的本机库  在libs文件夹和所有其他apk的libs文件夹中。

0 个答案:

没有答案
相关问题