【问题标题】:Could not find com.android.tools.build:gradle:3.4.2找不到 com.android.tools.build:gradle:3.4.2
【发布时间】:2019-08-30 12:47:55
【问题描述】:

安装nativescript-plugin-firebase 后,我无法再使用tns build android 构建我的应用程序。 我收到此错误:

nativescript-plugin-firebase: running release build or change in environment detected, forcing prepare!

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'nativescript_plugin_firebase'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:3.4.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
       - https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
     Required by:
         project :

这是我的platforms/android/build.gradle

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }
}

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

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

Hereplatforms/android/app/build.gradle

Hereplatforms/tempPlugin/nativescript_plugin_firebase/build.gradle

【问题讨论】:

  • 我认为 gradle 构建和工具版本不匹配
  • @JawadMalik 我该如何解决?
  • 显示应用级 build.gradle
  • 也分享你的 build.gradle 模块应用文件
  • @JawadMalik build.gradle 模块应用文件在哪里?

标签: android firebase gradle android-gradle-plugin nativescript


【解决方案1】:

您可能有另一个插件,具体取决于 Google Play 服务 (也许是谷歌地图)。我们需要固定到特定的播放服务 与其他人一起玩的版本,所以打开 app/App_Resources/Android/app.gradle 并添加:

示例

android {   
            project.ext {
            googlePlayServicesVersion = "15.0.0"   //"16.0.+
          }
       configurations.all {
             resolutionStrategy.force "com.google.android.gms:play-services-auth:$project.googlePlayServicesVersion"
           }
    }

如果出现同样的问题,请使用

classpath 'com.android.tools.build:gradle:3.4.1'

仅供参考Android plugin for Gradle HTTP proxy settings

defaultConfig {
        ...
        systemProp.http.proxyHost=proxy.company.com
        systemProp.http.proxyPort=443
        systemProp.http.proxyUser=userid
        systemProp.http.proxyPassword=password
        systemProp.http.auth.ntlm.domain=domain
    }

【讨论】:

  • 问题出在互联网连接上,您可以在答案中添加向 tns 添加代理的说明。
  • 请更新您的答案以包含这可能是由于网络问题引起的信息,并说明可以使用tns proxy set添加代理
猜你喜欢
  • 1970-01-01
  • 2019-11-22
  • 2021-12-16
  • 2019-05-12
  • 2019-11-06
  • 2019-12-27
  • 2020-02-08
  • 2017-04-11
  • 2018-09-05
相关资源
最近更新 更多