How to set up the SuperPowered SDK on Android

745 views Asked by At

Reading through the README on the SuperPowered SDK GitHub page, I notice that for having it working on Android you need to:

Create the jni folder inside the project's folder: app/src/main/jni Copy the contents of the following files from one of the example projects: gradle/wrapper/gradle-wrapper.properties, local.properties, build.gradle, app/build.gradle, app/src/main/jni/CMakeLists.txt Open build.gradle (Module: app), and change the applicationId

I've done all of that, still when I'm trying to sync my project with gradle, I get the following error message:

Error:(34, 0) Could not find method arguments() for arguments [-DANDROID_PLATFORM=android-16, -DANDROID_TOOLCHAIN=clang, -DANDROID_ARM_NEON=TRUE, -DANDROID_STL=gnustl_static, -DPATH_TO_SUPERPOWERED:STRING=null] on object of type com.android.build.gradle.internal.dsl.CmakeOptions. Open File

This is how my app/build.gradle looks like:

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')
    ....
}

EDIT:

Here is the cmake.txt file

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

There are 1 answers

0
FloHin On

I have a very similar config (as it inherits the default suggested config) but found some differences.

You provide the cmake config like this:

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

but as I understood you saved it as "cmake.txt" which is never linked or found.

Does renaming cmake.txt to CMakeLists.txt help?