如何在Android上设置SuperPowered SDK

时间:2017-09-02 13:43:28

标签: android gradle superpowered

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

  

在项目文件夹中创建jni文件夹:app / src / main / jni   从其中一个示例中复制以下文件的内容   projects: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] on 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
)

1 个答案:

答案 0 :(得分:0)

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

您可以像这样提供cmake配置:



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




但据我所知,你把它保存为" cmake.txt"从未被链接或找到。

是否将cmake.txt重命名为CMakeLists.txt帮助?