首页 > 解决方案 > android studio 3.6 中的 Gradle 同步失败

问题描述

Gradle 同步失败:不知道如何为 org.gradle.tooling.internal.gradle.DefaultGradleBuild@61cdce4 构建模型

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

allprojects {
    repositories {
        jcenter()
        maven { url "https://oss.sonatype.org/content/groups/public/" }
    }
}

build.gradle(模块:应用程序)

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.graphhopper.android"
        minSdkVersion 10
        targetSdkVersion 22
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {

        disable 'InvalidPackage'
    }
}



dependencies {
    compile(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.9-SNAPSHOT') {
       exclude group: 'com.google.protobuf', module: 'protobuf-java'
       exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
       exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
    }

    compile 'org.mapsforge:vtm:0.6.0'
    compile 'org.mapsforge:vtm-android:0.6.0'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi-v7a'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-x86'
    compile 'org.mapsforge:vtm-jts:0.6.0'
    compile 'org.mapsforge:vtm-themes:0.6.0'
    compile 'com.caverock:androidsvg:1.2.2-beta-1'
    compile 'com.vividsolutions:jts:1.13'

    compile 'org.slf4j:slf4j-api:1.7.21'
    compile 'org.slf4j:slf4j-android:1.7.21'
}

我正在使用安卓工作室 3.6。我无法构建项目。我试图使缓存/重启无效,但没有奏效。

标签: androidandroid-studiogradle

解决方案


请将类路径更新到最新版本并检查

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

buildscript {
    repositories {
        google()       //add here
        jcenter()
        maven { url "https://jitpack.io" }

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

allprojects {
    repositories {
        google()      //and here also
        jcenter()
        maven { url "https://jitpack.io" }

    }
}

构建.gradle(应用程序:)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "com.graphhopper.android"
        minSdkVersion 16
        targetSdkVersion 29
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {

        disable 'InvalidPackage'
    }
}


dependencies {
    compile(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.9-SNAPSHOT') {
        exclude group: 'com.google.protobuf', module: 'protobuf-java'
        exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
        exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
    }

    compile 'org.mapsforge:vtm:0.6.0'
    compile 'org.mapsforge:vtm-android:0.6.0'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi-v7a'
    compile 'org.mapsforge:vtm-android:0.6.0:natives-x86'
    compile 'org.mapsforge:vtm-jts:0.6.0'
    compile 'org.mapsforge:vtm-themes:0.6.0'
    compile 'com.caverock:androidsvg:1.2.2-beta-1'
    compile 'com.vividsolutions:jts:1.13'

    compile 'org.slf4j:slf4j-api:1.7.21'
    compile 'org.slf4j:slf4j-android:1.7.21'
}




推荐阅读