error adding symbols: File in wrong format

1,936 views
Skip to first unread message

Admir Maglajlic

unread,
Sep 23, 2019, 2:06:10 PM9/23/19
to android-ndk
.a: error adding symbols: File in wrong format


Hello All,

I am new to Android Studio and have following question:

I have included few external pre-build libraries from a vendor that have an ending in ". a".
Even though the project builds OK using the CMake, I get following error when I try to run the app on my tablet.

"Build command failed.
Error while executing process C:\Users\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\app\.cxx\cmake\arm7Debug\arm64-v8a --target hello-jni}
[1/2] Building C object CMakeFiles/hello-jni.dir/hello-jni.c.o
[2/2] Linking C shared library C:\Software\app\build\intermediates\cmake\arm7Debug\obj\arm64-v8a\libhello-jni.so
FAILED: cmd.exe /C "cd . && C:\Users\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe  --target=aarch64-none-linux-android23 --gcc-toolchain=C:/Users/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security  -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libhello-jni.so -o C:\app\build\intermediates\cmake\arm7Debug\obj\arm64-v8a\libhello-jni.so CMakeFiles/hello-jni.dir/hello-jni.c.o  C:/Software/MDP11_Demo_BLE/app/src/main/cpp/prebuilt_libs/libiaq.a C:/Software/MDP11_Demo_BLE/app/src/main/cpp/prebuilt_libs/libtvoc.a C:/app/src/main/cpp/prebuilt_libs/libr_cda.a C:/Software/MDP11_Demo_BLE/app/src/main/cpp/prebuilt_libs/libeco2.a C:/Software/MDP11_Demo_BLE/app/src/main/cpp/prebuilt_libs/libodor.a C:/Software/MDP11_Demo_BLE/app/src/main/cpp/prebuilt_libs/libzmod4410_calibration_co.a -landroid -llog -latomic -lm && cd ."
C:/app/src/main/cpp/prebuilt_libs/libiaq.a: error adding symbols: File in wrong format

clang: error: linker command failed with exit code 1 (use -v to see invocation)

ninja: build stopped: subcommand failed."

I am really stuck and any help is greatly appreciated.

Thank you,
Admir 

Dan Albert

unread,
Sep 23, 2019, 2:32:02 PM9/23/19
to android-ndk
C:/app/src/main/cpp/prebuilt_libs/libiaq.a

That's not an ABI-specific path. Presumably your working build and your failing build are for different ABIs, and you only have the library for one ABI. You need to match the ABI of the library to the ABI of your build. See https://developer.android.com/ndk/guides/abis for more information.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/e8de7228-876b-49a1-845d-1f990d4ab39e%40googlegroups.com.

Admir Maglajlic

unread,
Sep 23, 2019, 2:42:03 PM9/23/19
to android-ndk
Hello Dan,

I think you are 100% correct!

here is what I added to my build.gradle:

1. Inside my default config I added:

        ndk {

            abiFilters 'armeabi-v7a', 'x86'

        }


2. then I was getting "Duplicate Class" errors so I added following:

configurations.all {

    resolutionStrategy {

        force 'com.android.support:support-v4:27.1.0'

    }


Now I am able to run the app on my tablet.


Thank you for pointing out the missing ABI for my application.


-Admir

Reply all
Reply to author
Forward
0 new messages