How to setup CMake 3.18.1 in an Android project with gradle on Android Studio?
I executed the following steps:
downloaded the CMake 3.18.1 from Android Sdk - Sdk Tools (folder appeared correctly on Android/sdk/cmake with the 3.10 and 3.6 version)
I added the version requested on build.gradle as externalNativeBuild { cmake { version "3.18.1"
I added the path on local.properties as cmake.dir=/Users/bloom/Library/Android/sdk/cmake/3.18.1
I get the error message: C/C++ release|armeabi-v7a : CMake '3.18.1' found via cmake.dir='/Users/bloom/Library/Android/sdk/cmake/3.18.1' does not match requested version '3.10.2'. and the task failed is > Task :app:generateJsonModelDebug FAILED
I suspect there is a 3.10 version hardcoded somewhere, maybe on that task. In fact, undoing point 3 and requesting version 3.6 is ignored. With 3.10 I get an error on findBoost and it clearly shows that is using the 3.10 version, as you can see Make Warning at /Users/bloom/Library/Android/sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
Related
I am working on an Android native project which builds using CMake.
In my build.gradle I specify :
if(project.hasProperty("native")) {
externalNativeBuild {
cmake {
path file('jni/CMakeLists.txt')
version '3.18.1+'
}
}
}
I want to invoke externalNativeBuild task from command-line only on an automated build server.
However I am getting this error:
CMake '3.18.1' or higher was not found in SDK, PATH, or by cmake.dir property.
When I build it inside Android Studio normally, It downloads and install CMake but it is not happening from command-line.
Is there a way to do it from command-line?
Android studio will automatically create a local.properties file which contains the cmake.dir property.
When you build on the build server, it's more than likely that you your source doesn't have a local.properties file as that file is not normally checked into code repositories. You'll either need to create this file or modify the PATH environment variable to include the cmake binary. This of course presumes that you have CMake installed on the build server. You can do this manually with a .zip/.tarball or if you have access to the SDK on the build server, you can install with the build tools -> How to install Android SDK Build Tools on the command line?
Whenever I try to build my project I get this error message
"Caused by: org.gradle.api.InvalidUserDataException: NDK not configured. Download it with SDK manager. Preferred NDK version is '21.4.7075529'."
I have made sure NDK (side by side) is installed and ndk.dir=path is added to local.properties and ndkVersion is added to build.gradle. Is there anything else I'm missing??
Error information: NDK solution Result: Project settings: Gradle model version = 6.1, NDK version UNKNOWN
However, the NDK has been defined in the Project Structure > SDK location > Android NDK location: android \ sdk \ ndk \ 21.0.6113669.
What is the cause of the error?
If the synchronization is normal, the compilation is successful. However, if the synchronization is performed only, the APK file is not packed and generated. In this case, try Build->Build Bundle(s)/APK(s)->Build APK(s). The generated APK file is stored in the project directory\build\outputs\apk\debug directory.
The error message "NDK Resolution Outcome: Project settings: Gradle model version=6.1, NDK version is UNKNOWN" should be displayed in the Event Log, which does not affect the compilation of the project.
If the project fails to be compiled, provide the build error information.
If an error occurs, click Run build in the Build window to display the detailed error information.
I am on mac, using android studio 3.1.2 . I have changed the gradle version to 4.4 and Android plugin to 3.1.2
I have already changed the compile keyword to implementation in the build.gradle
I am getting this error :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':lint'.
> Could not resolve all files for configuration ':lintClassPath'.
> Could not find com.android.tools:sdk-common:26.1.2.
Searched in the following locations:
file:/Users/rp/Library/Android/sdk/extras/m2repository/com/android/tools/sdk-common/26.1.2/sdk-common-26.1.2.pom
file:/Users/rp/Library/Android/sdk/extras/m2repository/com/android/tools/sdk-common/26.1.2/sdk-common-26.1.2.jar
how can this be fixed?
The cause of this issue is that Gradle can't find the Android SDK. There are several ways to fix it:
Define the ANDROID_HOME environment variable
ANDROID_HOME=your/path/to/android/sdk; export ANDROID_HOME
or Add sdk.dir to the file local.properties, for example on my Linux computer
sdk.dir=/home/sdeng/Android/Sdk
if you already defined ANDROID_HOME or sdk.dir, it still happens. It probably something is wrong with the specific version of your Android SDK or Gradle daemon. Try to kill all Gradle processes, re-download the specific version of Android SDK.
Or you can check the SDK at $ANDROID_HOME/platforms/android-28, where 28 is the compileSdkVersion defined in build.gradle
Like other comment says, change to a good SDK version works in this case.
I have download ndk and start to make demo for "Hello World"
Make project with ref Android studio NDK
Download Cmake and put in sdk folder.
No change in code during gradle sync there is error like:
External Native Build Issues
Error while executing 'D:\android\Sdk\cmake\bin\cmake.exe' with arguments {-HD:\Data\Demo\TestNDK\app -BD:\Data\Demo\TestNDK\app\.externalNativeBuild\cmake\release\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=D:\android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\Data\Demo\TestNDK\app\.externalNativeBuild\cmake\release\obj\armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=D:\android\Sdk\cmake\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=D:\android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=22 -DCMAKE_CXX_FLAGS=-frtti -fexceptions}
CMake Error: Could not create named generator Android Gradle - Ninja
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Getting above error in default NDK Setting
Download Cmake and put in sdk folder.
You need to get cmake via the SDK manager to use it with Android Studio.