Android Studio 1.1.0 Gradle 项目同步失败在 OSX 上导入 Gradle 项目时出错

Android Studio 1.1.0 Gradle project sync failed Error importing a Gradle project on a OSX

我刚刚在这个文件夹中安装了 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 中找不到名称为 'default' 的配置

我试过了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()
    }
}

我刚刚下载了项目。

先看settings.gradle:

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

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

其次,看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

Dependencies

In order to compile the project the DFU Library is required. This project may be found here: https://github.com/NordicSemiconductor/Android-DFU-Library. Please clone the nRF Toolbox and the DFU Library to the same root folder. The dependency is already configured in the gradle and set to ..:DFULibrary:dfu module.

The nRF Toolbox also uses the nRF Logger API library which may be found here: https://github.com/NordicSemiconductor/nRF-Logger-API. The library (jar file) and is located in the libs folder and a jar with its source code in the source folder in the app module. This library allows the app to create log entries in the nRF Logger application. Please, read the library documentation on GitHub for more information about the usage and permissions.

The graph in HRM profile is created using the AChartEngine v1.1.0 contributed based on the Apache 2.0 license.

项目的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-库 DFULibrary)

你应该准备好了!