【问题标题】:Error 'features.h' file not found in QTCreator in a Android Project在 Android 项目的 QTCreator 中找不到错误 \'features.h\' 文件
【发布时间】:2022-08-19 03:45:15
【问题描述】:

我正在尝试通过 QTCreator 为 Android 编译一个应用程序。 特别是工具包 Qt 5.12.10 Clang arm64-v8a

我收到此错误消息:

######################################

在 C:/Qt/5.12.10/android_arm64_v8a/include/QtCore\\QObject:1 包含的文件中:

在 C:/Qt/5.12.10/android_arm64_v8a/include/QtCore/qobject.h:46 包含的文件中:

在 C:/Qt/5.12.10/android_arm64_v8a/include\\QtCore/qobjectdefs.h:48 包含的文件中:

在 C:/Qt/5.12.10/android_arm64_v8a/include\\QtCore/qnamespace.h:43 包含的文件中:

在 C:/Qt/5.12.10/android_arm64_v8a/include\\QtCore/qglobal.h:45 包含的文件中:

在 D:\\android\\sdk\\ndk\\23.1.7779620/sources/cxx-stl/llvm-libc++/include 包含的文件中 \\type_traits:416:

D:\\android\\sdk\\ndk\\23.1.7779620/sources/cxx-stl/llvm-libc++/include__config:218:12:致命错误:

\'features.h\' 文件未找到

#####################################

在我最后一次尝试中,我使用 Android Studio 下载了 sdk 和 ndk。 我试过的NDK版本是21、22、23和25

JDK 是 jdk1.8.0_341。

我在偏好设置->设备->Android 中的所有 Android 'Kits' 都有关于“未设置设备”的警告

已编辑

在亚历山大·迪亚吉列夫的建议下工作。 但是我遇到了 gradle 和 SDK 的问题。 然后我安装了 SDK 11 和 gradle 7.0.2,我进一步推进了一些步骤,但我有错误。

我的 build.gradle 是:

buildscript {
    repositories {
    maven { url \"https://maven.google.com\" }
    mavenCentral()
    google()
        jcenter()
    }

    dependencies {
        classpath \'com.android.tools.build:gradle:7.0.2\'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        mavenCentral()
    }
}

apply plugin: \'com.android.application\'

dependencies {
    implementation fileTree(dir: \'libs\', include: [\'*.jar\'])
    implementation \'com.android.support:appcompat-v7:+\'
    implementation \'com.google.android.gms:play-services:+\'
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qt5AndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/

    compileSdkVersion androidCompileSdkVersion.toInteger()

    buildToolsVersion androidBuildToolsVersion

    sourceSets {
        main {
            manifest.srcFile \'AndroidManifest.xml\'
            java.srcDirs = [qt5AndroidDir + \'/src\', \'src\', \'java\']
            aidl.srcDirs = [qt5AndroidDir + \'/src\', \'src\', \'aidl\']
            res.srcDirs = [qt5AndroidDir + \'/res\', \'res\']
            resources.srcDirs = [\'src\']
            renderscript.srcDirs = [\'src\']
            assets.srcDirs = [\'assets\']
            jniLibs.srcDirs = [\'libs\']
       }
    }

    lintOptions {
        abortOnError false
    }
    defaultConfig {
            applicationId \"com.comm5.visaocloud\"
        }
}

构建日志是:

16:17:33: Running steps for project cloudclient...
16:17:33: Starting: \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" clean -j16
del qrc_cloudclient_qmlcache.cpp
del qml_visaocloud_js.cpp qml_main_qml.cpp qml_content_LoginScreen_qml.cpp qml_content_ButtonControl_qml.cpp qml_content_SettingsScreen_qml.cpp qml_content_OeeIndice_qml.cpp qml_content_StackInformation_qml.cpp qml_content_MachineWidgetDelegateAutomatico_qml.cpp qml_content_DashboardScreen_qml.cpp qml_content_LineInformation_qml.cpp qml_content_FlipEffectImage_qml.cpp qml_content_MachineWidgetDelegateManual_qml.cpp qml_content_OeeMachineWidget_qml.cpp qml_content_DashboardUtils_js.cpp
del qmlcache_loader.cpp
del moc_predefs.h
del moc_dashboardlistmodel.cpp moc_notificationengine.cpp moc_hardwareutils.cpp moc_qjsonmodelarray.cpp
del main.moc
del main.obj dashboardlistmodel.obj deviceregistration.obj notificationengine.obj hardwareutils.obj JsonPath.obj qjsonmodelarray.obj deviceregistration_android.obj hardwareutils_android.obj qrc_cloudclient_qmlcache.obj qml_visaocloud_js.obj qml_main_qml.obj qml_content_LoginScreen_qml.obj qml_content_ButtonControl_qml.obj qml_content_SettingsScreen_qml.obj qml_content_OeeIndice_qml.obj qml_content_StackInformation_qml.obj qml_content_MachineWidgetDelegateAutomatico_qml.obj qml_content_DashboardScreen_qml.obj qml_content_LineInformation_qml.obj qml_content_FlipEffectImage_qml.obj qml_content_MachineWidgetDelegateManual_qml.obj qml_content_OeeMachineWidget_qml.obj qml_content_DashboardUtils_js.obj qmlcache_loader.obj moc_dashboardlistmodel.obj moc_notificationengine.obj moc_hardwareutils.obj moc_qjsonmodelarray.obj
del *~ core *.core
NÆo foi poss¡vel encontrar D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\*~
16:17:35: The process \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" exited normally.
16:17:35: Starting: \"C:\\Qt\\5.12.10\\android_armv7\\bin\\qmake.exe\" D:\\programming\\comm5\\visao\\cloudclient\\cloudclient.pro -spec android-clang \"CONFIG+=qtquickcompiler\"
16:17:37: The process \"C:\\Qt\\5.12.10\\android_armv7\\bin\\qmake.exe\" exited normally.
16:17:37: Starting: \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" -f D:/programming/comm5/visao/b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease/Makefile qmake_all
make: Nothing to be done for \'qmake_all\'.
16:17:38: The process \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" exited normally.
16:17:38: Starting: \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" -j16
C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++ -D__ANDROID_API__=16 -target armv7-none-linux-androideabi -gcc-toolchain C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 -fno-limit-debug-info -DANDROID_HAS_WSTRING --sysroot=C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147/sysroot -isystem C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147/sysroot/usr/include/arm-linux-androideabi -isystem C
.....


16:17:44: The process \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" exited normally.
16:17:44: Removing directory D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build/assets
16:17:44: Removing directory D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build/libs
16:17:44: Starting: \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" \"INSTALL_ROOT=D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\" install && cd D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease && C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe \"INSTALL_ROOT=D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\" install
C:\\Qt\\5.12.10\\android_armv7\\bin\\qmake.exe -install qinstall -exe ..\\bin\\deploy\\libcloudclient.so D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\libs\\armeabi-v7a\\libcloudclient.so
C:\\Qt\\5.12.10\\android_armv7\\bin\\qmake.exe -install qinstall -exe ..\\bin\\deploy\\libcloudclient.so D:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\libs\\armeabi-v7a\\libcloudclient.so
16:17:48: The process \"C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\ndk\\21.3.6528147\\prebuilt\\windows-x86_64\\bin\\make.exe\" exited normally.
16:17:48: Starting: \"C:\\Qt\\5.12.10\\android_armv7\\bin\\androiddeployqt.exe\" --input D:/programming/comm5/visao/b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease/android-libcloudclient.so-deployment-settings.json --output D:/programming/comm5/visao/b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease/android-build --android-platform android-21 --jdk \"C:/Program Files/Java/jdk-11.0.16\" --gradle
Generating Android Package
  Input file: D:/programming/comm5/visao/b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease/android-libcloudclient.so-deployment-settings.json
  Output directory: D:/programming/comm5/visao/b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease/android-build/
  Application binary: D:/programming/comm5/visao/bin/deploy/libcloudclient.so
  Android build platform: android-21
  Install to device: No
Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
Warning: elemento inesperado (uri:\"\", local:\"base-extension\"). Os elementos esperados são <{}codename>,<{}layoutlib>,<{}api-level>
  -- Skipping C:/Qt/5.12.10/android_armv7/plugins/iconengines/libqsvgicon.so. It has unmet dependencies: lib/libQt5Svg.so.
  -- Skipping C:/Qt/5.12.10/android_armv7/plugins/imageformats/libqsvg.so. It has unmet dependencies: lib/libQt5Svg.so.
> Task :preBuild UP-TO-DATE
> Task :preDebugBuild UP-TO-DATE
> Task :compileDebugRenderscript
> Task :generateDebugBuildConfig
> Task :javaPreCompileDebug
> Task :checkDebugAarMetadata
> Task :generateDebugResValues
> Task :generateDebugResources
> Task :compileDebugAidl FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task \':compileDebugAidl\'.
> A failure occurred while executing com.android.build.gradle.tasks.AidlCompile$AidlCompileRunnable
   > > Task :mergeDebugResources
com.android.ide.common.process.ProcessException: Error while executing process C:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\build-tools\\33.0.0\\aidl.exe with arguments {-pC:\\Users\\Paoli\\AppData\\Local\\Android\\Sdk\\platforms\\android-21\\framework.aidl -oD:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\build\\generated\\aidl_source_output_dir\\debug\\out -IC:\\Qt\\5.12.10\\android_armv7\\src\\android\\java\\src -ID:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\src -ID:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\aidl -ID:\\programming\\comm5\\visao\\b-cloudclient-And_Qt_5_12_10_Clarmv7aRelease\\android-build\\src\\debug\\aidl -IC:\\Users\\Paoli\\.gradle\\caches\\transforms-3\\48a46c27b0d9b79f33541fa222ce4db4\\transformed\\support-media-compat-26.1.0\\aidl -IC:\\Users\\Paoli\\.gradle\\caches\\transforms-3\\192ad8f6a0f651ff9f10305663e68198\\transformed\\support-compat-28.0.0\\aidl -IC:\\Users\\Paoli\\.gradle\\caches\\transforms-3\\5d596afbbf514aaec8702eb472ca97f3\\transformed\\versionedparcelable-28.0.0\\aidl -dC:\\Users\\Paoli\\AppData\\Local\\Temp\\aidl14331251136729576369.d C:\\Qt\\5.12.10\\android_armv7\\src\\android\\java\\src\\org\\kde\\necessitas\\ministro\\IMinistro.aidl}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use \'--warning-mode all\' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
7 actionable tasks: 7 executed
Warning: QML import could not be resolved in any of the import paths: br.com.comm5
Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
Building the android package failed!
  -- For more information, run this command with --verbose.
16:18:28: The process \"C:\\Qt\\5.12.10\\android_armv7\\bin\\androiddeployqt.exe\" exited with code 14.
Error while building/deploying project cloudclient (kit: Android Qt 5.12.10 Clang armeabi-v7a)
The kit Android Qt 5.12.10 Clang armeabi-v7a has configuration issues which might be the root cause for this problem.
When executing step \"Build Android APK\"
16:18:28: Elapsed time: 00:56.

我还执行了命令:

gradlew.bat --info  build clean --stacktrace

结果是

Initialized native services in: C:\\Users\\Paoli\\.gradle\\native
Found daemon DaemonInfo{pid=25160, address=[c2b63990-e0d8-4817-ad20-5308929c843b port:53261, addresses:[/127.0.0.1]], state=Idle, lastBusy=1660756380138, context=DefaultDaemonContext[uid=badf4a2e-2eb1-4075-bba8-1291894fe5dd,javaHome=C:\\Program Files\\Java\\jdk1.8.0_281,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=25160,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]} however its context does not match the desired criteria.
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\\Program Files\\Java\\jdk-11.0.16,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=77640,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]
Actual: DefaultDaemonContext[uid=badf4a2e-2eb1-4075-bba8-1291894fe5dd,javaHome=C:\\Program Files\\Java\\jdk1.8.0_281,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=25160,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]

  Looking for a different daemon...
Found daemon DaemonInfo{pid=42916, address=[f37e5b97-0c13-437c-9fa9-cb3379a13472 port:58153, addresses:[/127.0.0.1]], state=Idle, lastBusy=1660768619876, context=DefaultDaemonContext[uid=feb33525-5510-4ed1-b91a-1d728494e115,javaHome=C:\\Program Files\\Java\\jdk-11.0.16,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=42916,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]} however its context does not match the desired criteria.
At least one daemon option is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\\Program Files\\Java\\jdk-11.0.16,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=77640,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]
Actual: DefaultDaemonContext[uid=feb33525-5510-4ed1-b91a-1d728494e115,javaHome=C:\\Program Files\\Java\\jdk-11.0.16,daemonRegistryDir=C:\\Users\\Paoli\\.gradle\\daemon,pid=42916,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=BR,-Duser.language=pt,-Duser.variant]

  Looking for a different daemon...
The client will now receive all logging from the daemon (pid: 56268). The daemon log file: C:\\Users\\Paoli\\.gradle\\daemon\\7.0.2\\daemon-56268.out.log
Starting 15th build in daemon [uptime: 2 hrs 27 mins 22.878 secs, performance: 100%, non-heap usage: 30% of 256 MiB]
Using 16 worker leases.
Now considering [D:\\programming\\comm5\\visao\\cloudclient\\native\\android] as hierarchies to watch
Not watching anything anymore
Watching the file system is enabled if available
Starting Build
Settings evaluated using settings file \'D:\\programming\\comm5\\visao\\cloudclient\\native\\android\\settings.gradle\'.
Projects loaded. Root project using build file \'D:\\programming\\comm5\\visao\\cloudclient\\native\\android\\build.gradle\'.
Included projects: [root project \'android\']

> Configure project :
Evaluating root project \'android\' using build file \'D:\\programming\\comm5\\visao\\cloudclient\\native\\android\\build.gradle\'.
Invalidating in-memory cache of C:\\Users\\Paoli\\.gradle\\caches\\journal-1\\file-access.bin
Invalidating in-memory cache of C:\\Users\\Paoli\\.gradle\\caches\\7.0.2\\fileHashes\\fileHashes.bin
Invalidating in-memory cache of C:\\Users\\Paoli\\.gradle\\caches\\7.0.2\\fileHashes\\resourceHashesCache.bin

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use \'--warning-mode all\' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
Not watching anything anymore
Watched directory hierarchies: []

以及来自同一命令的错误(2>gradle_error.txt)

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file \'D:\\programming\\comm5\\visao\\cloudclient\\native\\android\\build.gradle\' line: 44

* What went wrong:
A problem occurred evaluating root project \'android\'.
> Could not get unknown property \'androidCompileSdkVersion\' for extension \'android\' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

* Try:
Run with --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project \'android\'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
    at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:136)

....

==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring root project \'android\'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* Try:
Run with --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project \'android\'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)

我的 androidManifest.xml

<?xml version=\"1.0\"?>
<manifest package=\"com.comm5.visaocloud\" xmlns:android=\"http://schemas.android.com/apk/res/android\" android:versionName=\"1.5.64\" android:versionCode=\"12\" android:installLocation=\"auto\">
    <application android:debuggable=\"false\" android:hardwareAccelerated=\"true\" android:name=\"org.qtproject.qt5.android.bindings.QtApplication\" android:label=\"Visao Cloud\" android:icon=\"@drawable/icon\" android:theme=\"@android:style/Theme.Holo\">
        <activity android:configChanges=\"orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation\" android:name=\"com.comm5.visaocloud.MainActivity\" android:label=\"Visao Cloud\" android:screenOrientation=\"unspecified\" android:launchMode=\"singleTop\">
            <intent-filter>
                <action android:name=\"android.intent.action.MAIN\"/>
                <category android:name=\"android.intent.category.LAUNCHER\"/>
            </intent-filter>
            <meta-data android:name=\"android.app.lib_name\" android:value=\"-- %%INSERT_APP_LIB_NAME%% --\"/>
            <meta-data android:name=\"android.app.qt_sources_resource_id\" android:resource=\"@array/qt_sources\"/>
            <meta-data android:name=\"android.app.repository\" android:value=\"default\"/>
            <meta-data android:name=\"android.app.qt_libs_resource_id\" android:resource=\"@array/qt_libs\"/>
            <meta-data android:name=\"android.app.bundled_libs_resource_id\" android:resource=\"@array/bundled_libs\"/>
            <!-- Deploy Qt libs as part of package -->
            <meta-data android:name=\"android.app.bundle_local_qt_libs\" android:value=\"-- %%BUNDLE_LOCAL_QT_LIBS%% --\"/>
            <meta-data android:name=\"android.app.bundled_in_lib_resource_id\" android:resource=\"@array/bundled_in_lib\"/>
            <meta-data android:name=\"android.app.bundled_in_assets_resource_id\" android:resource=\"@array/bundled_in_assets\"/>
            <!-- Run with local libs -->
            <meta-data android:name=\"android.app.use_local_qt_libs\" android:value=\"-- %%USE_LOCAL_QT_LIBS%% --\"/>
            <meta-data android:name=\"android.app.libs_prefix\" android:value=\"/data/local/tmp/qt/\"/>
            <meta-data android:name=\"android.app.load_local_libs\" android:value=\"-- %%INSERT_LOCAL_LIBS%% --\"/>
            <meta-data android:name=\"android.app.load_local_jars\" android:value=\"-- %%INSERT_LOCAL_JARS%% --\"/>
            <meta-data android:name=\"android.app.static_init_classes\" android:value=\"-- %%INSERT_INIT_CLASSES%% --\"/>
            <!--  Messages maps -->
            <meta-data android:value=\"@string/ministro_not_found_msg\" android:name=\"android.app.ministro_not_found_msg\"/>
            <meta-data android:value=\"@string/ministro_needed_msg\" android:name=\"android.app.ministro_needed_msg\"/>
            <meta-data android:value=\"@string/fatal_error_msg\" android:name=\"android.app.fatal_error_msg\"/>
            <!--  Messages maps -->
            <!-- Splash screen -->
            <!--
            <meta-data android:name=\"android.app.splash_screen_drawable\" android:resource=\"@drawable/logo\"/>
            -->
            <!-- Splash screen -->
            <!-- Background running -->
            <!-- Warning: changing this value to true may cause unexpected crashes if the
                          application still try to draw after
                          \"applicationStateChanged(Qt::ApplicationSuspended)\"
                          signal is sent! -->
            <meta-data android:name=\"android.app.background_running\" android:value=\"false\"/>
            <!-- Background running -->
        </activity>
        <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\"/>
        <!-- [START gcm_receiver] -->
        <receiver android:name=\"com.google.android.gms.gcm.GcmReceiver\" android:exported=\"true\" android:permission=\"com.google.android.c2dm.permission.SEND\">
            <intent-filter>
                <action android:name=\"com.google.android.c2dm.intent.RECEIVE\"/>
                <category android:name=\"com.comm5.visaocloud\"/>
                <action android:name=\"com.google.android.c2dm.intent.REGISTRATION\"/>
            </intent-filter>
        </receiver>
        <!-- [END gcm_receiver] -->
        <!-- [START gcm_listener] -->
        <service android:name=\"com.comm5.visaocloud.MyGcmListenerService\">
            <meta-data android:name=\"android.app.lib_name\" android:value=\"-- %%INSERT_APP_LIB_NAME%% --\"/>
        </service>
        <!-- [END gcm_listener] -->
        <!-- [START instanceId_listener] -->
        <service android:name=\"com.comm5.visaocloud.MyInstanceIDListenerService\">
            <meta-data android:name=\"android.app.lib_name\" android:value=\"-- %%INSERT_APP_LIB_NAME%% --\"/>
        </service>
        <!-- [END instanceId_listener] -->
        <service android:name=\"com.comm5.visaocloud.RegistrationIntentService\">
            <meta-data android:name=\"android.app.lib_name\" android:value=\"-- %%INSERT_APP_LIB_NAME%% --\"/>
        </service>
    </application>

    <supports-screens android:largeScreens=\"true\" android:normalScreens=\"true\" android:anyDensity=\"true\" android:smallScreens=\"true\"/>

    <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
         Remove the comment if you do not require these default permissions. -->
    <!-- %%INSERT_PERMISSIONS -->

    <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
         Remove the comment if you do not require these default features. -->
    <!-- %%INSERT_FEATURES -->

    <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>
    <uses-permission android:name=\"android.permission.INTERNET\"/>
    <uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>
    <uses-permission android:name=\"android.permission.VIBRATE\"/>
    <uses-permission android:name=\"android.permission.WAKE_LOCK\"/>

    <permission android:name=\"com.comm5.visaocloud.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\"/>
    <uses-permission android:name=\"com.comm5.visaocloud.permission.C2D_MESSAGE\"/>
<uses-sdk android:minSdkVersion=\"21\" android:targetSdkVersion=\"21\"/>
</manifest>

我的 QtCreator 项目经理

    标签: android qt android-ndk qt-creator


    【解决方案1】:

    这是由不受支持的 NDK 版本引起的。你需要:

    1. 在 Android Studio (21.3.6528147) 中为 Qt 5.12 安装正确版本的 Android NDK。
    2. 确保在 Qt Creator 的设置中默认选中它。 这是我的设置截图。默认 NDK 使用斜体字体编写。
    3. 一个可选的东西,可能还需要指定ANDROID_NDK_PLATFORM 环境变量。您可以在 Qt Creator 的设置中更改它,但我建议全局设置(在系统的环境变量中)。它的值应该是android-21

      附言在所有这些更改之后,不要忘记清理和重建项目。

    【讨论】:

    • 谢谢@Alexander,您的建议似乎解决了这个问题。我还不确定,因为与这篇文章的主题无关的其他问题(我认为是关于 gradle)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多