如何修复,尝试支持64位时找不到libcocos2dcpp.so

问题描述 投票:0回答:1

[我在android studio中有一个cocos2dx游戏,当我尝试使其支持64位要求时,我收到此错误“当我在手机上启动项目时找不到” libcocos2dcpp.so“”

为了支持64位,我做了什么:我在cocos2dx论坛上搜索了支持64位的解决方案,然后找到了一个解决方案:*我修改了Application.MK文件:添加APP_ABI:= armeabi armeabi-v7a arm64-v8a* gradle.properties:添加PROP_APP_ABI = armeabi-v7a:arm64-v8a* build.gradle:添加ndk.abiFilters'armeabi-v7a','arm64-v8a'

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.xxxxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/base.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_resources_apk.apk", zip file "/data/app/com.xxxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.xxxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.xxxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.xxxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.xxx.kidslearngame-oq27wbETBHeT2MFhWg9cOw==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libcocos2dcpp.so"

这些是我找到的解决方案,但是当我在手机上运行该应用程序时,它崩溃了,并给了我上面的错误,但是当我从gradle.build中删除了ndk.abiFilters'armeabi-v7a','arm64-v8a'时,它正在工作很好,但是当我将其上传到Play商店时,他们向我显示警告消息“您的应用不支持64位要求”

c++ android-studio cocos2d-x
1个回答
0
投票

也许您应该清除项目,然后在Android Studio中从菜单中选择文件->使缓存无效/重新启动

下面给出适合我的设置:

在Application.mk中

APP_ABI := arm64-v8a

在gradle.properties中

PROP_APP_ABI=armeabi-v7a:arm64-v8a

在app / build.gradle中

android {
    compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
    buildToolsVersion PROP_BUILD_TOOLS_VERSION

    def versionMajor = 0
    def versionMinor = 9
    def versionPatch = 0
    def versionBuild = 0

    defaultConfig {
        applicationId "YOUR APP ID"
        minSdkVersion PROP_MIN_SDK_VERSION
        targetSdkVersion PROP_TARGET_SDK_VERSION
        // versionCode 1
        // versionName "1.0"
        versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"

        externalNativeBuild {
            if (PROP_BUILD_TYPE == 'ndk-build') {
                ndkBuild {
                    targets 'MyGame'
                    arguments 'NDK_TOOLCHAIN_VERSION=clang'
                    arguments '-j' + Runtime.runtime.availableProcessors()
                }
            }
            else if (PROP_BUILD_TYPE == 'cmake') {
                cmake {
                    targets 'MyGame'
                    arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE", \
                              "-DUSE_CHIPMUNK=TRUE", "-DUSE_BULLET=TRUE"
                    cppFlags "-frtti -fexceptions"
                    // prebuilt root must be defined as a directory which you have right to access or create if you use prebuilt
                    // set "-DGEN_COCOS_PREBUILT=ON" and "-DUSE_COCOS_PREBUILT=OFF" to generate prebuilt,  this way build cocos2d-x libs
                    // set "-DGEN_COCOS_PREBUILT=OFF" and "-DUSE_COCOS_PREBUILT=ON" to use prebuilt, this way not build cocos2d-x libs
                    //arguments "-DCOCOS_PREBUILT_ROOT=/Users/laptop/cocos-prebuilt"
                    //arguments "-DGEN_COCOS_PREBUILT=OFF", "-DUSE_COCOS_PREBUILT=OFF"
                }
            }
        }

        ndk {
            abiFilters = []
            abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
        }
    }

    splits {
        // Configures multiple APKs based on ABI.
        abi {
            // Enables building multiple APKs per ABI.
            enable true
            //enable gradle.startParameter.taskNames.contains(":app:assembleRelease")
            //enable project.hasProperty('splitApks')

            // 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 true
        }
    }

    // Map for the version code that gives each ABI a value.
    def abiCodes = ['x86':3, 'x86_64':4, 'armeabi-v7a':1, 'arm64-v8a':2]

    // APKs for the same app that all have the same version information.
    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) * 1000000 + android.defaultConfig.versionCode
        }
    }
. . . . . . . . .
. . . . . . . . .

我希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.