简体   繁体   中英

Qt Creator: Android settings have errors. NDK directory structure isn't correct and installed in a path with spaces

I've been experiencing this issue for 2 months. Qt Creator indicates that ndk path and directory have issues though the messages are confusing.

This happens with every Android Kit.

In Qt Creator, looking at Options -> Devices -> Android , Android Settings display two error messages with red 'X' on the left side:

  1. "X Android NDK directory structure is correct."
  2. "X Android NDK installed into a path without spaces."

I don't have no idea what message 1 is trying to tell me, here is the structure of the directory:

.
├── build
├── meta
├── ndk-build
├── ndk-depends
├── ndk-gdb
├── ndk-which
├── NOTICE
├── NOTICE.toolchain
├── prebuilt
├── python-packages
├── README.md
├── shader-tools
├── simpleperf
├── sysroot
├── toolchains
└── wrap.sh

Regarding the second error message this is the path:

/home/user/Android/android-ndk-r18b

I can't see how could be a space in the above path.

When I try to build any Project with Android Kit, I receive the following error at the output:

opt/Qt/5.12.0/android_armv7/include/QtCore/qglobal.h:45:12: fatal error: 'type_traits' file not found

Info:

  • Ubuntu 18.04;
  • Qt 5.12.0;
  • Qt Creator 4.8;

I faced this problem in my project based on Ubuntu 18.04 , To avoid some errors, I highly recommend you to download Android NDK on Android Studio:

Android Studio > Tools > SDK Manager > SDK Tools > NDK (Side by side),

As shown in the following picture:

安卓NDK

After that, it will be installed under:

/home/(UserName)/Android/Sdk/ndk

So I had chosen this path as Android Ndk path, but this was the wrong path as @Oshio said in the 2nd part of his answer, you must choose the path which is under "ndk" path, in my case:

/home/(UserName)/Android/Sdk/ndk/20.0.5594570

As shown in the following picture:

Qt 设备 Android

For me worked with an older version of NDK.

Also it didn't worked if I manually downloaded the NDK. But when I downloaded the NDK from the Android Studio it works.

Hope it helps :)

The root of all this trouble were two silly mistakes when unzipping the downloaded ndk.

  1. The first error is the one that motivated me to post this question and is related with my low end computer and my Ubuntu 18.04. When unzipping files, the OS doesn't provides any message warning me that the process has finished. My computer takes ~2 min to complete the extraction, so my guess is that I did a copy and paste of the folder before all the files were extracted.

After taking notice from this fact and downloaded again the ndk, but I was getting the same errors, although I was sure the extraction was successful. And here is the another silly mistake:

  1. When unzipping the ndk, a folder is created, which contains another folder with nearly identical name, here's the structure:

    ...android-ndk-r19c-linux-x86_64/android-ndk-r19c/

    In the Qt Creator I was providing the path to ...android-ndk-r19c-linux-x86_64/ and not to ...android-ndk-r19c-linux-x86_64/android-ndk-r19c/ , after altering to the correct path everything worked fine.

Important Note: From Qt5.12 forward, is recommended to use the latest ndk version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM