【问题标题】:Android Studio 1.1.0 Gradle project sync failed Error importing a Gradle project on a OSXAndroid Studio 1.1.0 Gradle 项目同步失败 在 OSX 上导入 Gradle 项目时出错
【发布时间】:2015-06-17 22:33:40
【问题描述】:

我刚刚在这个文件夹中安装了 gradle: /Users/joanet/Development/gradle-2.3

编辑文件launchd.conf

sudo vim /etc/launchd.conf

设置变量 GRAILS_HOME

setenv GRAILS_HOME /Users/joanet/Development/gradle-2.3

然后我已经导入了项目https://github.com/NordicSemiconductor/Android-nRF-Toolbox

使用文件 -> 导入项目

但我得到了这个错误: Gradle 项目同步失败错误:在 Android Studio 中找不到名称为“默认”的配置

我试过这个https://www.youtube.com/watch?v=8RwVvZtNTaM 但它没有工作

这里是 build.gradle 文件:

// 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:1.1.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

这里是/app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.0'
    defaultConfig {
        applicationId "no.nordicsemi.android.nrftoolbox"
        minSdkVersion 18
        targetSdkVersion 22
        versionCode 30
        versionName "1.12.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile project(':..:DFULibrary:dfu')
    compile files('libs/achartengine-1.1.0.jar')
    compile files('libs/nrf-logger-v2.0.jar')
}

这里 settings.gradle:

include ':app', '..:DFULibrary:dfu'

这里是 gradle-wrapper.properties:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip


// 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:1.1.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

【问题讨论】:

  • 发布 BOTH 您的 build.gradle 文件。你错过了你的“应用程序”build.gradle
  • 请同时发布您的settings.gradle 文件。
  • 我花时间下载了该项目,以便帮助您完成它。请看我的回答。

标签: android macos android-studio android-gradle-plugin cradle


【解决方案1】:

我刚刚下载了项目。

先看settings.gradle

include ':app', '..:DFULibrary:dfu'

有一个项目,..:DFULibrary:dfu,Github 项目中没有提供。

其次,看app/build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile project(':..:DFULibrary:dfu') // <-- You do not have this
    compile files('libs/achartengine-1.1.0.jar')
    compile files('libs/nrf-logger-v2.0.jar')
}

compile project(':..:DFULibrary:dfu') 行正在尝试编译您没有的项目。

三、阅读README.md

依赖关系

为了编译项目,需要 DFU 库。这 项目可以在这里找到: https://github.com/NordicSemiconductor/Android-DFU-Library。请 将 nRF 工具箱和 DFU 库克隆到同一根文件夹。这 依赖项已在 gradle 中配置并设置为 ..:DFULibrary:dfu 模块。

nRF 工具箱还使用 nRF Logger API 库,它可能是 在这里找到:https://github.com/NordicSemiconductor/nRF-Logger-API。这 库(jar 文件),位于 libs 文件夹和一个 jar 它的源代码在 app 模块的源文件夹中。这个图书馆 允许应用程序在 nRF Logger 应用程序中创建日志条目。 请阅读 GitHub 上的库文档以获取更多信息 关于使用和权限。

HRM 配置文件中的图表是使用 AChartEngine v1.1.0 创建的 基于 Apache 2.0 许可证贡献。

项目的owner 在此处为您提供其他项目站点的 URL:https://github.com/NordicSemiconductor/Android-DFU-Library

结论:

只需按照他在与您当前项目相同文件夹中的说明中所说的那样执行git clone https://github.com/NordicSemiconductor/Android-DFU-Library.git。之后一切都应该正常工作。

如何:

  1. git clone https://github.com/NordicSemiconductor/Android-nRF-Toolbox.git

  2. git clone https://github.com/NordicSemiconductor/Android-DFU-Library.git

  3. Android-DFU-Library 重命名为DFULibrary。 (mv Android-DFU-Library DFULibrary)

你应该准备好了!

【讨论】:

    猜你喜欢
    • 2015-01-16
    • 2014-07-03
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-22
    相关资源
    最近更新 更多