我的应用程序运行良好,然后我添加了com.splunk:mint-android-sdk,这需要gradle的更高版本,因此我将gradle升级到了2.1到3.3。之后,我面临问题。请查看我的gradle文件并为我提供帮助,并指导我它的工作方式。(这是我的第一个应用程序,但我想确保其在所有情况下都可以正常工作)

Error:Could not find com.android.tools.build:gradle:3.3.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.jar
    https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.3/gradle-3.3.jar
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.3/gradle-3.3.jar
Required by:
    :MyApp:unspecified

我的gradleare
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

    android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.example.abc.myApp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled= true
        manifestPlaceholders = [onesignal_app_id: "hjaadsffsddd8-2e6hgf-4fdsasdfgb63-8dad5-1111111",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

    compile 'com.onesignal:OneSignal:[3.6.1,3.99.99]'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'
    compile 'com.splunk:mint-android-sdk:5.2.1'
}


// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3'
       classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.splunk:mint-gradle-android-plugin:5.2.1'
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

在buildscript内添加google(),然后打开终端写入命令-gradlew build并按Enter。

android - 错误:Could not find com. android.tools.build :gradle:3. 3.升级splunk的gradle版本后出现问题:mint-android-sdk-LMLPHP

repositories {
    google()
    jcenter()
}

注意:请确保您处于 Activity 网络连接中

09-25 21:05