Error:(52, 0) Gradle DSL method not found: 'сompile()' in using Quickblox API

Error:(52, 0) Gradle DSL method not found: 'сompile()' in using Quickblox API

我尝试通过添加在线 Maven 依赖项在我的程序中使用 Quickblox API。 我正在使用 Android Studio。
当我尝试构建我的程序时,它显示以下错误:

Error:(52, 0) Gradle DSL method not found: `сompile()` Possible causes:
  • The project 'Nanny Watch' may be using a version of Gradle that does not contain the method.
    Open Gradle wrapper file
  • The build file may be missing a Gradle plugin.
    Apply Gradle plugin
  • 这是 build.gradle(项目:NannyWatch2)文件:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
    
            jcenter()
        }
    }
    

    这里是 build.gradle(Module:App) 文件:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.example.user.nannywatch"
            minSdkVersion 16
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        def qbSdkVersion = '2.5'
    
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'org.apache.commons:commons-lang3:3.4'
        compile 'net.schmizz:sshj:0.10.0'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.android.support:multidex:1.0.0'
        compile('vc908.stickers:stickerfactory:0.2.2@aar') {
            transitive = true;
        }
        compile 'com.google.android.gms:play-services-gcm:7.5.0'  
    
    // I tried using jar compile, but the method QBPushNotifications cannot be resolved
    // Therefore I tried to use the online repository
    
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-chat-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-content-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-core-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-customobjects-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-location-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-messages-2.4.jar')
    //    compile files('src/main/java/com/example/user/nannywatch/jars/quickblox-android-sdk-videochat-webrtc-2.4.jar')  
    
        сompile "com.quickblox:quickblox-android-sdk-core:$qbSdkVersion@aar"
        сompile ("com.quickblox:quickblox-android-sdk-chat:$qbSdkVersion@aar"){
            transitive=true
        }
        сompile "com.quickblox:quickblox-android-sdk-content:$qbSdkVersion@aar"
        сompile "com.quickblox:quickblox-android-sdk-messages:$qbSdkVersion@aar"
        сompile "com.quickblox:quickblox-android-sdk-customobjects:$qbSdkVersion@aar"
        сompile "com.quickblox:quickblox-android-sdk-location:$qbSdkVersion@aar"
        сompile "com.quickblox:quickblox-android-sdk-videochat-webrtc:$qbSdkVersion@aar"
    }
    

    还有这个警告:'dependencies' cannot be applied to '(groovy.lang.Closure)' Image

    这可能是 Gradle 版本错误的结果。

    使用了以下版本:

    • 'com.android.tools.build:gradle:1.3.0' 用于 Gradle Android 插件
    • gradleVersion = '2.4' 对于 Gradle

    https://github.com/QuickBlox/quickblox-android-sdk/blob/master/build.gradle

    这很奇怪"bug"。当您从 Quickblox 复制并粘贴 Gradle 行时,您在单词 compile 中复制了字母 "c" 的错误 ASCII 代码,并且 Gradle 无法识别单词 "compile".

    • 从 Quickblox 站点复制的 "c" 的 ASCII 码是 209 129
    • "c"的ASCII码是99

    你可以自己尝试使用这个 link: string to ASCII

    • 普通字母 → c
    • Quickblox 字母 → с

    转换每个字母,您将得到不同的 ASCII 码。

    所以解决方法很简单,把字母c删掉自己写:)