Error:(1, 0) Gradle version 2.2 is required. Current version is 3.4.1.

在导入Github项目时,Android Studio可能因Gradle版本不匹配导致问题。例如,2.3版本项目使用3.3,而2.4版本使用3.4.1。当2.4版本AS导入2.3项目时,需要手动调整Gradle版本。有时AS能自动修复,但有时需要手动修改gradle-wrapper.properties和build.gradle文件。

我们在使用Android Studio的时候新建项目没什么问题的,但是当我们下载一份Github上的项目导入进去的时候却没法正常使用,其原因主要是gradle配置问题。而由于gradle这个玩意儿版本更新太快,Android Studio每个版本也不一样。比如2.3版本使用gradle的版本是3.3,而2.4版本使用的是3.4.1.那么这个时候会出现什么问题呢?当你使用Android Studio 2.4版本导入一个2.3版本的项目的话就会出现需要修改gradle的版本。有时候Android Studio比较智能会自己修改的,但是有时候就没那么幸运了,比如下面这个图:


Error:(1, 0) Gradle version 2.2 is required. Current version is 3.4.1.
Please fix the project's Gradle settings.
<a href="fixGradleVersionInWrapper">Fix Gradle wrapper and re-import project</a><br><a href="openGradleSettings">Gra
ERROR: Failed :entry:default@BuildNativeWithCmake... > hvigor ERROR: Exceptions happened while executing: Not searching for unused variables given on the command line. CMake Warning (dev) at CMakeLists.txt:1 (project): cmake_minimum_required() should be called prior to this top-level project() call. Please see the cmake-commands(7) manual for usage documentation of both commands. This warning is for project developers. Use -Wno-dev to suppress it. CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Deprecation Warning at E:/MyApplicationRn/entry/oh_modules/@rnoh/react-native-openharmony/src/main/cpp/CMakeLists.txt:6 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Deprecation Warning at E:/MyApplicationRn/entry/oh_modules/@rnoh/react-native-openharmony/src/main/cpp/third-party/boost/libs/predef/CMakeLists.txt:23 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. -- Boost.Context: architecture arm64, binary format elf, ABI aapcs, assembler gas, suffix .S, implementation fcontext Experimental C-API architecture enabled CMake Error at CMakeLists.txt:23 (add_subdirectory): The binary directory E:/MyApplicationRn/entry/.cxx/default/default/debug/arm64-v8a/permissions is already used to build a source directory. It cannot be used to build source directory E:/MyApplicationRn/entry/oh_modules/@react-native-oh-tpl/react-native-permissions/src/main/cpp Specify a unique binary directory name. -- Configuring incomplete, errors occurred!鸿蒙项目运行报错
最新发布
08-15
我有一份C代码,配置文件如CMakeLists.txt: cmake_minimum_required(VERSION 3.4.1) project(RKFace VERSION 1.0.0) # 设置 C++ 标准 set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) # 基本编译选项 set(CMAKE_C_FLAGS "-Wall -fPIC -O2") set(CMAKE_CXX_FLAGS "-Wall -fPIC -O2") # Android 平台配置 if(CMAKE_SYSTEM_NAME STREQUAL "Android") add_definitions(-DANDROID) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() # 包含目录 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include src/rknn_sunchip.h ) # 源文件 set(main_source src/cmain.cc) # 库文件路径 set(LIBPATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/android) # 链接库 set(LINKS ${LIBPATH}/libRKFace.so ${LIBPATH}/libnva.so ${LIBPATH}/librknnrt.so ) # Android 特定库 if(CMAKE_SYSTEM_NAME STREQUAL "Android") list(APPEND LINKS log c++_shared) endif() # 标准库 list(APPEND LINKS c m dl) # 生成可执行文件 add_executable(rkface.demo ${main_source}) # 链接库 target_link_libraries(rkface.demo ${LINKS}) # 设置安装目录为当前目录下的 install set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/install) # 定义共享库 sunchip_rknn add_library(sunchip_rknn SHARED src/rknn_sunchip.c ) # 设置符号可见性控制 target_compile_options(sunchip_rknn PRIVATE -fvisibility=hidden # 隐藏所有符号 -fno-builtin # 防止内置符号冲突 ) # 定义导出宏 target_compile_definitions(sunchip_rknn PRIVATE -DAPI_EXPORT=__attribute__\(\(visibility\(\"default\"\)\)\) ) # 添加链接器选项 target_link_options(sunchip_rknn PRIVATE "-Wl,--exclude-libs=ALL" # 隐藏依赖库符号 "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version_script.map" ) # 将包含目录添加到 yolov8_pose 库 target_include_directories(sunchip_rknn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/rknn_sunchip.h ) # 安装可执行文件到 install/bin install(TARGETS rkface.demo RUNTIME DESTINATION bin) # 安装库文件到 install/lib install(FILES ${LIBPATH}/libRKFace.so ${LIBPATH}/libnva.so ${LIBPATH}/librknnrt.so DESTINATION lib ) # 安装头文件到 install/include (如果需要) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" ) # 安装共享库 install(TARGETS sunchip_rknn RUNTIME DESTINATION lib) 但是我生成出来的sunchip_rknn库导入android studio以后报错无法找到rknn_sunchip.h 内部的方法,报错如下:Execution failed for task &#39;:app_rknn_face_demp:buildCMakeDebug[arm64-v8a]&#39;. > com.android.ide.common.process.ProcessException: ninja: Entering directory `D:\AndroidProject\Application_721_rknn\app_rknn_face_demp\.cxx\Debug\6n3i5l6d\arm64-v8a&#39; [1/2] Building CXX object CMakeFiles/rknn4j.dir/src/main/cpp/native-lib.cc.o [2/2] Linking CXX shared library ..\..\..\..\build\intermediates\cxx\Debug\6n3i5l6d\obj\arm64-v8a\librknn4j.so FAILED: ../../../../build/intermediates/cxx/Debug/6n3i5l6d/obj/arm64-v8a/librknn4j.so cmd.exe /C "cd . && C:\Users\16270\AppData\Local\Android\Sdk\ndk\25.2.9519653\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android24 --sysroot=C:/Users/16270/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -std=c++11 -fexceptions -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,librknn4j.so -o ..\..\..\..\build\intermediates\cxx\Debug\6n3i5l6d\obj\arm64-v8a\librknn4j.so CMakeFiles/rknn4j.dir/src/main/cpp/native-lib.cc.o -Wl,--no-undefined ../../../../src/main/jniLibs/arm64-v8a/libsunchip_rknn.so ../../../../src/main/jniLibs/arm64-v8a/librknnrt.so ../../../../src/main/jniLibs/arm64-v8a/libRKFace.so ../../../../src/main/jniLibs/arm64-v8a/libnva.so ../../../../src/main/jniLibs/arm64-v8a/libc++_shared.so C:/Users/16270/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib/aarch64-linux-android/24/liblog.so -latomic -lm && cd ." ld: error: undefined symbol: sunchip_face_init >>> referenced by native-lib.cc:10 (D:/AndroidProject/Application_721_rknn/app_rknn_face_demp/src/main/cpp/native-lib.cc:10) >>> CMakeFiles/rknn4j.dir/src/main/cpp/native-lib.cc.o:(Java_com_rockchip_gpadc_demo_yolo_InferenceWrapper_native_1inityolov8) clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
06-17
This error message means that the Gradle version being used by the project is not compatible with the required version. To fix this issue, you can either update the Gradle version of your project to version 2.2 or downgrade the current Gradle version to version 2.2. To update the Gradle version of your project, you can follow these steps: 1. Open the build.gradle file of your project. 2. Find the line that specifies the Gradle version, it should look like this: `classpath &#39;com.android.tools.build:gradle:3.0.0&#39;` 3. Replace the Gradle version number with the required version number, which is 2.2: `classpath &#39;com.android.tools.build:gradle:2.2.0&#39;` 4. Sync your project with the Gradle files to apply the changes. If you want to downgrade the current Gradle version to version 2.2, you can follow these steps: 1. Open the Gradle distribution website at https://services.gradle.org/distributions/ 2. Download the Gradle version 2.2 distribution by clicking on the link that says `gradle-2.2-all.zip` 3. Extract the downloaded file into a new folder on your computer. 4. Open the `gradle/wrapper/gradle-wrapper.properties` file of your project. 5. Change the following line: `distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip` 6. To: `distributionUrl=file:///path/to/gradle-2.2-all.zip` 7. Replace `/path/to/gradle-2.2-all.zip` with the actual path to the extracted Gradle 2.2 distribution on your computer. 8. Sync your project with the Gradle files to apply the changes. After following either of these steps, the project should now be using the required Gradle version and the error message should no longer appear.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

养-乐多

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值