2

阅读SuperPowered SDK GitHub页面上的自述文件,我注意到要让它在 Android 上运行,您需要:

在项目文件夹中创建 jni 文件夹:app/src/main/jni 从示例项目之一复制以下文件的内容:gradle/wrapper/gradle-wrapper.properties、local.properties、build.gradle、app/ build.gradle, app/src/main/jni/CMakeLists.txt 打开build.gradle (Module: app),修改applicationId

我已经完成了所有这些,但当我尝试将我的项目与 gradle 同步时,我收到以下错误消息:

错误:(34, 0) 在类型对象上找不到参数 [-DANDROID_PLATFORM=android-16, -DANDROID_TOOLCHAIN=clang, -DANDROID_ARM_NEON=TRUE, -DANDROID_STL=gnustl_static, -DPATH_TO_SUPERPOWERED:STRING=null] 的方法 arguments() com.android.build.gradle.internal.dsl.CmakeOptions。打开文件

这就是我的 app/build.gradle 的样子:

apply plugin: 'com.android.application'

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def superpowered_sdk_path = properties.getProperty('superpowered.dir')

android {
    signingConfigs {
        dancam_dev_key {
            keyAlias ######
            keyPassword ######
            storeFile file('/Users/daniele/Desktop/Chords/#####')
            storePassword ########
        }
    }
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId #####
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 17
        versionName "2.1"
        signingConfig #######
        multiDexEnabled true

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // these platforms cover 99% percent of all Android devices
        }
    }

    externalNativeBuild {
        cmake {
            arguments '-DANDROID_PLATFORM=android-16', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_STL=gnustl_static', "-DPATH_TO_SUPERPOWERED:STRING=${superpowered_sdk_path}"
            cFlags '-O3', '-fsigned-char' // full optimization, char data type is signed
            cppFlags '-fsigned-char', "-I${superpowered_sdk_path}"
        }
    }

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }

    dataBinding {
        enabled = true
    }
}

sourceSets {
    main {
        jniLibs.srcDirs = ['src/main/jni']
    }
}

externalNativeBuild {
    cmake {
        path 'src/main/jni/CMakeLists.txt'
    }
}

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

编辑:

这是cmake.txt文件

cmake_minimum_required(VERSION 3.4.1)

set(
    PATH_TO_SUPERPOWERED
    CACHE STRING ""
)

message(${ANDROID_ABI})

file(GLOB CPP_FILES "*.cpp")

add_library(
    SuperpoweredExample
    SHARED
    ${CPP_FILES}
    ${PATH_TO_SUPERPOWERED}/AndroidIO/SuperpoweredAndroidAudioIO.cpp
)

include_directories(src/main/jni)
include_directories(${PATH_TO_SUPERPOWERED})

target_link_libraries(
    SuperpoweredExample
    log
    android
    OpenSLES
    ${PATH_TO_SUPERPOWERED}/libSuperpoweredAndroid${ANDROID_ABI}.a
)
4

1 回答 1

0

我有一个非常相似的配置(因为它继承了默认的建议配置),但发现了一些差异。

您提供这样的 cmake 配置:

externalNativeBuild {
    cmake {
        path 'src/main/jni/CMakeLists.txt'
    }
}

但据我了解,您将其保存为从未链接或找到的“cmake.txt”。

将 cmake.txt 重命名为 CMakeLists.txt 有帮助吗?

于 2018-06-08T07:11:09.830 回答