【问题标题】:Gradle project sync completed with some errors (Cannot sync)Gradle 项目同步已完成,但出现一些错误(无法同步)
【发布时间】:2016-10-04 14:56:11
【问题描述】:

我的 build.gradle 有错误。我尝试链接到 Github 项目,但失败了。

build.gradle(项目:XXXX)

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

buildscript {
    repositories {
          //mavenCentral()
        maven { url "https://maven/jjhesk" }
       jcenter()

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

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

allprojects {
    repositories {
            mavenCentral()
        maven { url "https://maven/jjhesk" }
        jcenter()

    }
}

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

build.gradle(模块:XXXX)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.google.testingtimer"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    /* compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })*/
    //compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.github.pheynix:TimerView:660400fb64'
    //androidTestCompile 'junit:junit:4.12'
}

我尝试按照本网站上的这些说明进行操作:

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 你得到的错误信息是什么?
  • @sanastasiadis Error(1,0) 无法为根项目获取未知属性“构建”
  • 问题:你有build.gradle(Project:XXXX)作为你根项目的build.gradle的第一行吗?你不应该。

标签: android compilation dependencies repository android-gradle-plugin


【解决方案1】:

我今天也犯了同样的错误。为了解决这个问题,我打开了 build.gradle 文件并替换了 2 的出现:

repositories {
    jcenter()
}

repositories {
    maven { url "http://jcenter.bintray.com" }
    jcenter()
}

在我的情况下,问题是由 代理 引起的。 https 有问题,然后我强制使用 http

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-08
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多