Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIN10 下无法编译! AS3.1.2 NDK 17.0.4754217 #28

Closed
0xffc2 opened this issue May 29, 2018 · 5 comments
Closed

WIN10 下无法编译! AS3.1.2 NDK 17.0.4754217 #28

0xffc2 opened this issue May 29, 2018 · 5 comments

Comments

@0xffc2
Copy link

0xffc2 commented May 29, 2018

Android Studio 3.1.2
Windows 10 10.0
NDK 17.0.4754217

Build command failed.
Error while executing process C:\Users\aaa\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\aaa\Desktop\ld\dumpDex-develop\app.externalNativeBuild\cmake\debug\x86_64 --target nativeDump}
[1/8] Building C object CMakeFiles/nativeDump.dir/src/main/cpp/dlopen.c.o
[2/8] Building C object CMakeFiles/nativeDump.dir/src/main/cpp/inlineHook.c.o
[3/8] Building CXX object CMakeFiles/nativeDump.dir/src/main/cpp/native.cpp.o
[4/8] Building CXX object CMakeFiles/nativeDump.dir/src/main/cpp/util/fileutils.cpp.o
[5/8] Building CXX object CMakeFiles/nativeDump.dir/src/main/cpp/And64InlineHook.cpp.o
[6/8] Building C object CMakeFiles/nativeDump.dir/src/main/cpp/relocate.c.o
[7/8] Building CXX object CMakeFiles/nativeDump.dir/src/main/cpp/util/deviceutils.cpp.o
FAILED: C:\Users\aaa\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=x86_64-none-linux-android --gcc-toolchain=C:/Users/aaa/AppData/Local/Android/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/aaa/AppData/Local/Android/Sdk/ndk-bundle/sysroot -DnativeDump_EXPORTS -isystem C:/Users/aaa/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/nativeDump.dir/src/main/cpp/inlineHook.c.o -MF CMakeFiles\nativeDump.dir\src\main\cpp\inlineHook.c.o.d -o CMakeFiles/nativeDump.dir/src/main/cpp/inlineHook.c.o -c C:\Users\aaa\Desktop\ld\dumpDex-develop\app\src\main\cpp\inlineHook.c
In file included from C:\Users\aaa\Desktop\ld\dumpDex-develop\app\src\main\cpp\inlineHook.c:19:
C:/Users/aaa/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include\arm-linux-androideabi/asm/ptrace.h:21:10: fatal error: 'asm/hwcap.h' file not found
#include <asm/hwcap.h>
^~~~~~~~~~~~~
1 error generated.

@wangkunlin
Copy link

我的也编译不通过,使用 百度云下载的 apk 里面的 so 是 64 的,但是我要dump 的是 32 的程序,加载失败。过不去了

@0xffc2
Copy link
Author

0xffc2 commented May 29, 2018

我是这样解决的

build.gradle 注释的 ndk abiFilters 取消注释 改为
ndk { abiFilters "armeabi-v7a","arm64-v8a" }

CMakeLists.txt 后面增加

if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
else()
include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android)
endif()

@wangkunlin
Copy link

wangkunlin commented May 29, 2018

找到解决办法了,把 app.gradle 里的

 ndk { // 注释解开
            abiFilters "armeabi", "armeabi-v7a","arm64-v8a"
        }

然后,在 CMakeLists.txt 增加下面的代码

if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
    include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androidabi)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
    include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
else()
    include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androidabi)
endif()

编译就能通过了。

@wangkunlin
Copy link

@McPan 可以,估计我们看的是同一个文章解决的

@wangkunlin
Copy link

参考链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants