无法解决gradle的外部依赖关系 [英] Cannot resolve external dependency for gradle

查看:1360
本文介绍了无法解决gradle的外部依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了许多与类似问题有关的问题,但找不到有效的解决方案.这可能是我对Android开发的经验不足,但我认为错误消息并不十分清楚.我尝试过:

I have looked through many of the issues regarding similar problems but i could not find a solution that works. It might be my inexperience with android development but i don't think that the error message is all that clear. I have tried:

  • 重建/清理项目,
  • 使缓存无效/重新启动,同步
  • 带有gradle文件的项目,
  • 我在设置中使用默认的gradle包装器,

关于解决该问题的任何想法?

Any ideas on what to do to solve this one?

使用Android Studio版本:3.4.1

Using Android Studio version: 3.4.1

应用程序:Build.gradle

App: Build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.app.jokr.dogpark"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-firestore:19.0.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
    testImplementation 'junit:junit:4.13-beta-3'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
}

buildscript {
    ext {
        var = '3.3.2'
    }
    dependencies {
        classpath 'com.android.tools.build:gradle'
    }
}

apply plugin: 'com.google.gms.google-services'

项目:Build.gradle

Project: Build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties:

gradle-wrapper.properties:

#Mon May 20 12:04:18 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

构建失败并返回:

Cannot resolve external dependency com.android.tools.build:gradle because no repositories are defined.

推荐答案

删除此无意义的部分:

buildscript {
    ext {
        var = '3.3.2'
    }
    dependencies {
        classpath 'com.android.tools.build:gradle'
    }
}

这篇关于无法解决gradle的外部依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆