Question

I am new to Android and I am about to deal with BLE app. So I downloaded and installed the Android Studio 0.4.6 on Windows XP w SP3, and Updated it to 0.5.4.

Then, I went to http://developer.android.com/samples/index.html and downloaded the BluetoothLeGatt.zip (http://developer.android.com/downloads/samples/BluetoothLeGatt.zip) for my project.

When I tried "Import Project" to use the BluetoothLeGatt project, it failed with the message:

Failed to refresh Gradle project 'BluetoothLeGatt' The project is using an unsupported version of Gradle. Please use version 1.10. Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) Fix Gradle wrapper and re-import project Gradle settings

I clicked "Fix Gradle wrapper and re-import project Gradle settings" and got the message:

Quick Fix Failed Unable to find any references to the Android Gradle plug-in in build.gradle files. Please click the link to perform a textual search and then update the build files manually.

The file build.gradle is:

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android'

dependencies {
    // Add the support lib that is appropriate for SDK 18
    compile "com.android.support:support-v13:19.0.+"
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
    'main',     // main sample code; look here for the interesting stuff.
    'common',   // components that are reused by multiple samples
    'template'] // boilerplate code that is generated by the sample template process

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    sourceSets {
        main {
            dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
            }
        }
        instrumentTest.setRoot('tests')
        instrumentTest.java.srcDirs = ['tests/src']
    }
}

Well, I am new in Android, so I don't know how to fix it, and I don't know what documents I should go through first that will help me to solve it.

Need help badly.

Was it helpful?

Solution

In build.gradle set your classpath to 0.9.+

classpath 'com.android.tools.build:gradle:0.9.+'

Then in gradle/wrapper/gradle-wrapper.properties you will need to check your distributionUrl The error is quite miss pointing making one belive that the problem is only within the build.gradle file.

Using gradle:0.9.+ your distributionUrl in gradle-wrapper.properties should be set to: http\://services.gradle.org/distributions/gradle-1.10-all.zip

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

###Correct distributionUrl###
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip

Then sync gradle, clean and rebuild project and you should be good to go

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top