Android Studio Project需要较早版本的Gradle

时间:2017-07-18 10:52:34

标签: android qt android-studio gradle

我正在尝试编译一些Android Studio项目,但收到此错误消息:

Gradle sync failed: Gradle version 2.2 is required. Current version is 3.3.

当我点击消息附近的fix issue链接时,我收到了:

Gradle sync failed: Could not find property 'androidCompileSdkVersion' on com.android.build.gradle.AppExtension_Decorated@580ec9dd.

在文件'android-build'中我有:

/*******************************************************
 * 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']
   }
}

2 个答案:

答案 0 :(得分:1)

更改项目根build.gradle文件的gradle版本,如下所示

,

或者将其更改为已升级到的最新gradle版本。

答案 1 :(得分:0)

在我使用Qt 5.11.1的情况下,最简单的解决方法是从android build目录中复制gradle.properties文件,使其位于build.gradle旁边。

我在这里找到它

build-MyApp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Release / android-build / gradle.properties

复制后,Android Studio即可同步。确保不提交该文件!如果升级Qt,则需要复制另一张。