3

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.

Quey
  • 33
  • 3
  • When did you download this? The relevant file is BluetoothLeGatt/gradle/wrapper/gradle-wrapper.properties but I downloaded it just now and it points to the right version of Gradle. – Scott Barta Apr 14 '14 at 15:19
  • Oh, I tried it again as I saw your post. It points to the right version now. But another error message came out: Error:com.android.support:support-v13:19.1.+ (double-click here to find usages.) It's in file build.gradle dependencies {...} – Quey Apr 14 '14 at 23:21

1 Answers1

0

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

Mathias Asberg
  • 3,562
  • 6
  • 30
  • 46
  • Still failed to run in device: Waiting for device. Target device: samsung-gt_i9500-4d0034e2564f60bb Uploading file local path: C:\ADT\Projects\BluetoothLeGatt\BluetoothLeGattSample\build\apk\BluetoothLeGattSample-debug-unaligned.apk remote path: /data/local/tmp/com.example.android.bluetoothlegatt Installing com.example.android.bluetoothlegatt DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.android.bluetoothlegatt" pkg: /data/local/tmp/com.example.android.bluetoothlegatt Failure [INSTALL_FAILED_OLDER_SDK] – Quey Apr 18 '14 at 09:06
  • Excuse me, I am newbie in Android world, shall I accept the answer (will it close this thread?) and open another question or try some more here? – Quey Apr 18 '14 at 09:14
  • @Quey That's another question so you open a new thread because i don't think they have anything to do with each other. But you have the answer here maybe: http://stackoverflow.com/questions/9093709/installation-error-install-failed-older-sdk Try to lower the API version i gradle file ( Not needed in Manifest like they write there, so lower your version ) Or use emulator with higher API compatibility – Mathias Asberg Apr 18 '14 at 10:32
  • Thanks, I think I can solve it, "Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low Energy", so the firmware of samsung-gt_i9500 (API 17) need update. – Quey Apr 19 '14 at 02:59