Lorsque je crée un projet Android qui comprend du code NDK. J'ai eu l'erreur suivante:
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/debug/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/Android.toolchain.cmake -DANDROID_PLATFORM=Android-14 -DCMAKE_CXX_FLAGS=}
/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/release/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/release/obj/armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/Android.toolchain.cmake -DANDROID_PLATFORM=Android-14 -DCMAKE_CXX_FLAGS=}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
J'essaie de localiser la cause.
J'ai trouvé ce qui suit:
gongzelong@gongzelong:~/Android/Sdk/cmake/3.6.4111459/bin$ cmake -version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/home/gongzelong/Android/Sdk/cmake/3.6.4111459/share/cmake-3.5
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Il semble que le cmake ait séparément les versions 3.5 et 3.6.
Quelqu'un pourrait-il indiquer comment le corriger et créer le projet Android avec succès?
Mise à jour:
Je supprime le cmake et l'installe à nouveau dans Android studio sdk manager.
J'ai toujours ceci:
null
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/debug/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/debug/obj/armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/Android.toolchain.cmake -DANDROID_PLATFORM=Android-14 -DCMAKE_CXX_FLAGS=}
/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Build command failed.
Error while executing process /home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app -B/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/.externalNativeBuild/cmake/release/armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=/home/gongzelong/Android/Sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/media/gongzelong/Toshiba/Code/Code/ImageLoaderEncapsulation/ImageLoader/ImageLoaderDemo/app/build/intermediates/cmake/release/obj/armeabi -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/home/gongzelong/Android/Sdk/cmake/3.6.4111459/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/home/gongzelong/Android/Sdk/ndk-bundle/build/cmake/Android.toolchain.cmake -DANDROID_PLATFORM=Android-14 -DCMAKE_CXX_FLAGS=}
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Il semble que vous utilisiez une version NDK qui ne prend plus en charge certains ABI (armeabi dans votre journal d'erreurs), vous devez donc mettre à niveau build in build.gradle (Project: ....) to le dernier
classpath 'com.Android.tools.build:gradle:3.1.3'
Et dans gradle-wraper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.Zip
Et enfin, vous devez ajouter abiFilters dans Android bloc de votre build.gradle (Module: app) selon les ABI dont vous avez besoin :
Android {
....
defaultConfig {
externalNativeBuild {
cmake {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
}
}
}
....
}
Dans mon cas, les changements suivants dans build.gradle (Module: app) m'aident.
Original
Android {
....
defaultConfig {
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=gnustl_static' ... [other args]
}
}
}
....
}
Avec mes changements
Android {
Android.buildToolsVersion "28.0.3"
....
defaultConfig {
externalNativeBuild {
cmake {
'-DANDROID_STL=c++_static' ... [other args]
}
}
}
....
}
J'ai la même erreur, et mon bundle ndk est le plus récent, qui est ndk-r18b
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage Configuring incomplete, errors occurred!
Je le corrige en utilisant Android-ndk-r14b, vous pouvez le spécifier dans local.properties
ndk.dir=/Users/xxxx/Library/Android/sdk/Android-ndk-r14b
Bien sûr, vous devez d'abord télécharger r14b et le décompresser sous le dossier sdk