1. 编译一直提示error configuration
解决:修改build.gradle文件
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
2. 有多个cpp文件
复制下面代码,修改native-lib为自身cpp名称
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
复制下面代码,修改native-lib为自身cpp名称
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} )
3. 设置so库生成路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/./libs/${ANDROID_ABI})
4. 更新最新版本的NDK或者Cmake
5. 查看CPP文件存储格式是否是UTF-8
本文详细介绍了在Android开发中遇到的CPP编译错误及解决方案,包括修改Gradle配置、设置SO库路径、更新NDK/CMake等,帮助开发者快速定位并解决问题。
7万+

被折叠的 条评论
为什么被折叠?



