加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React-Native Android,仅适用于armeabi架构

发布时间:2020-12-15 05:06:49 所属栏目:百科 来源:网络整理
导读:注意:我正在提供这些库,我不能为其他架构制作其他库. 我目前正在移植一个Android应用程序,以反应本机使用本机库,但我只有armeabi可用.到目前为止,原始项目没有问题,自armeabi is supported by all the x86/x86_64/armeabi-v7a/arm64-v8a devices以来. 然后
注意:我正在提供这些库,我不能为其他架构制作其他库.

我目前正在移植一个Android应用程序,以反应本机使用本机库,但我只有armeabi可用.到目前为止,原始项目没有问题,自armeabi is supported by all the x86/x86_64/armeabi-v7a/arm64-v8a devices以来.

然后当我从react-native生成一个新项目并包含那些armeabi文件时,在运行apk时找不到一些库.当我解压缩原始项目生成的apk时,我可以找到文件夹:lib / armeabi包含所有库,所以没问题.现在,当我解压由react-native生成的apk时,我有2个文件夹:lib / armeabi-v7a和lib / x86,并且缺少一些库.

这是我的反应原生的gradle配置:

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.poc"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a","x86"
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true,also generate a universal APK
            include "armeabi-v7a","x86"
        }
    }

    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro"
        }

        veryVerbose {

        }
    }

    signingConfigs {
        releaseConfig {
        }

        buildTypes {
            release {
                debuggable true
                jniDebuggable false
                signingConfig signingConfigs.releaseConfig
            }
        }
    }

    // applicationVariants are e.g. debug,release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture,set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1,"x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug,universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile fileTree(dir: "libs",include: ["*.jar"])

    // Player library
    veryVerboseCompile fileTree(dir: 'veryVerboseLibs',include: ['*.jar'])
    debugCompile fileTree(dir: 'releaseLibs',include: ['*.jar'])
    releaseCompile fileTree(dir: 'releaseLibs',include: ['*.jar'])

    // Google
    compile "com.android.support:appcompat-v7:23.0.1"

    // Square
    compile 'com.jakewharton:butterknife:8.2.1'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'

    // From node_modules
    compile "com.facebook.react:react-native:+"
}

看起来像react-native自动生成一些关于体系结构的配置,对我来说有点新鲜,我需要告诉gradle为armeabi构建并将所有这些库包含在我的最终apk中的lib / armeabi文件夹中.

基本上我从logcat和运行apk获得的是:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.siminntvpoc-2/base.apk"],nativeLibraryDirectories=[/data/app/com.siminntvpoc-2/lib/x86,/data/app/com.siminntvpoc-2/base.apk!/lib/x86,/vendor/lib,/system/lib]]] couldn't find "libViewRightWebClient.so"
您必须在application.mk中指定所需的架构类型.

要支持所有体系结构,请在application.mk文件中使用此属性APP_ABI:= all

这是文件https://developer.android.com/ndk/guides/application_mk.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读