Home » Android » macos – Android Studio 1.1.0 Gradle project sync failed Error importing a Gradle project on a OSX

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

Posted by: admin May 14, 2020 Leave a comment

Questions:

I just installed gradle in this folder:
/Users/joanet/Development/gradle-2.3

edit the file launchd.conf

sudo vim /etc/launchd.conf

to set the variable GRAILS_HOME

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

then I’ve imported the project https://github.com/NordicSemiconductor/Android-nRF-Toolbox

using File -> Import project

but I got this error:
Gradle project sync failed and Error: Configuration with name ‘default’ not found in Android Studio

I have tried this https://www.youtube.com/watch?v=8RwVvZtNTaM
but it has not worked

enter image description here

Here the file 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()
    }
}

and here /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')
}

here settings.gradle:

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

and here 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()
    }
}
How to&Answers:

I just downloaded the project.

First look at the settings.gradle:

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

There is a project, ..:DFULibrary:dfu, that is not provided in the Github project.

Second, look at the 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')
}

The line, compile project(':..:DFULibrary:dfu') is trying to compile a project that you do not have.

Third, read the 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.

The owner of the project provides you with the other project site’s URL here: https://github.com/NordicSemiconductor/Android-DFU-Library.

Conclusion:

Simply do git clone https://github.com/NordicSemiconductor/Android-DFU-Library.git just like he says in his instructions in the same folder as your current project. Everything should work after that.

How to:

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

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

  3. Rename Android-DFU-Library to DFULibrary. (mv Android-DFU-Library DFULibrary)

You should be all set!