2

I built superpowered example app located here: https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/blob/master/Android/CrossExample/

But when I tried to run on a phone (API16) - I got this error:

01-14 12:53:51.906 7800-7800/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             java.lang.ExceptionInInitializerError
                                                 at java.lang.Class.newInstanceImpl(Native Method)
                                                 at java.lang.Class.newInstance(Class.java:1319)
                                                 at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2022)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132)
                                                 at android.app.ActivityThread.access$700(ActivityThread.java:140)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
                                                 at android.os.Handler.dispatchMessage(Handler.java:99)
                                                 at android.os.Looper.loop(Looper.java:137)
                                                 at android.app.ActivityThread.main(ActivityThread.java:4918)
                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                 at java.lang.reflect.Method.invoke(Method.java:511)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
                                                 at dalvik.system.NativeStart.main(Native Method)
                                              Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1307]:   133 cannot locate 'strtof'...

                                                 at java.lang.Runtime.loadLibrary(Runtime.java:370)
                                                 at java.lang.System.loadLibrary(System.java:535)
                                                 at com.superpowered.crossexample.MainActivity.<clinit>(MainActivity.java:125)
                                                 at java.lang.Class.newInstanceImpl(Native Method) 
                                                 at java.lang.Class.newInstance(Class.java:1319) 
                                                 at android.app.Instrumentation.newActivity(Instrumentation.java:1068) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2022) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132) 
                                                 at android.app.ActivityThread.access$700(ActivityThread.java:140) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:137) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4918) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 
                                                 at dalvik.system.NativeStart.main(Native Method) 

I tried to change ndk version to build:

  android.ndk {
        platformVersion = 15
}

And got this error on build:

    /Volumes/iMect/iphone/SuperpoweredSource/decoder/SuperpoweredDecoder.cpp:549: error: undefined reference to 'strtof'
/Volumes/iMect/iphone/SuperpoweredSource/net/net.cpp:69: error: undefined reference to 'signal'
/Volumes/iMect/iphone/SuperpoweredSource/net/net.cpp:69: error: undefined reference to 'signal'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

Also I made changes into gradle.build file to make build possible using AndroidStudio 2.1

Added line toolchain "clang",and added flag -fno-exceptions instead of -fexceptions

android.ndk {
        toolchain "clang"
      cppFlags.addAll(["-fno-exceptions", "-fsigned-char", "-I${superpowered_sdk_path}".toString()])

}
Kirill Akhmetov
  • 318
  • 4
  • 12

2 Answers2

3

An update of the library has been released! Use the last version of superpoweredSDK and everything will be fine. Gabor Szanto said(How to build app with Superpowered lib for NDK less than 23?) that it's good from 16, I tested on my device and it compiled and ran without any errors.

Community
  • 1
  • 1
Kirill Akhmetov
  • 318
  • 4
  • 12
1

The android.ndk.platformVersion setting in the build gradle doesn't limit your application to run on older devices. It just sets which NDK version to build with. You can safely set it to 23 (Android 6.0 Marshmallow), and your application will still run on devices with older versions of Android.

The android.defaultConfig.minSdkVersion.apiLevel setting does set your Android app's lower limit, but it's an Android SDK setting, not related to the NDK. You can set that to any lower value, down to 11 (NDK and OpenSL ES appeared with 11). I recommend 19 (4.4 KitKat), because it's the first Android version with proper scheduling for audio. 75% of all active devices today are compatible with that.

Gabor Szanto
  • 1,329
  • 8
  • 12