android - 如何使用 Superpowered lib 为 NDK 小于 23 构建应用程序?

标签 android c++ android-ndk build.gradle

我构建了位于此处的 super 示例应用程序: https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine/blob/master/Android/CrossExample/

但是当我尝试在手机(API16)上运行时 - 我收到此错误:

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) 

我尝试更改 ndk 版本来构建:

  android.ndk {
        platformVersion = 15
}

构建时出现此错误:

    /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)

我还对 gradle.build 文件进行了更改,以便可以使用 AndroidStudio 2.1 进行构建

添加了行工具链“clang”,并添加了标志 -fno-exceptions 而不是 -fexceptions

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

}

最佳答案

库的更新已发布! 使用最新版本的 superpoweredSDK 一切都会好起来的。 Gabor Szanto 说( How to build app with Superpowered lib for NDK less than 23? )从 16 开始就很好,我在我的设备上进行了测试,它编译并运行没有任何错误。

关于android - 如何使用 Superpowered lib 为 NDK 小于 23 构建应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37372974/

相关文章:

c# - Google Protocol Buffers - 固定大小的缓冲区?

android - 在 Android 上编译 NEON 代码时出错

android - 切换到较新版本的 android ndk 时未定义的模块

安卓 : merging static libraries into single one

android - 具有相同内核的 ARM SoC 之间有很大差异吗?

android - 将 Android-Gradle 项目导入 Android Studio

android - 在不同位置应用不同命令

android - 在Android中使用NDK(C/C++)对图像应用灰度效果

C++基于子类型动态转换结构

c++ - WSARecv() 可以立即返回数据吗?