BLE on Android, the easy way. THIS IS NOW DEPRECATED. Please visit website for info on new versions.
BLE on Android, the easy way. THIS IS NOW DEPRECATED. Please visit website for info on new versions.
| Why? | Features | Getting Started | Licensing | Wiki | Toolbox
Android's BLE stack has some...issues...
SweetBlue is a blanket abstraction that shoves all that troublesome behavior behind a clean interface and gracefully degrades when the underlying stack becomes too unstable for even it to handle.
It’s built on the hard-earned experience of several commercial BLE projects and provides so many transparent workarounds to issues both annoying and fatal that it’s frankly impossible to imagine writing an app without it. It also supports many higher-level constructs, things like atomic transactions for coordinating authentication handshakes and firmware updates, flexible scanning configurations, read polling, transparent retries for transient failure conditions, and, well, the list goes on. The API is dead simple, with usage dependence on a few plain old Java objects and link dependence on standard Android classes. It offers conveniences for debugging and analytics and error handling that will save you months of work - last mile stuff you didn't even know you had to worry about.
MyApp/src/main/lib/. This ZIP contains several samples, precompiled JARS, and API docs and is preferable to downloading from GitHub, which only contains the raw source.build.gradle file.```
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 18
targetSdkVersion 25
...
}
sourceSets {
main.java.srcDirs += 'src/main/lib/sweetblue/src'
main.res.srcDirs += 'src/main/lib/sweetblue/res'
...
}
...
}
``````
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 18
targetSdkVersion 25
...
}
sourceSets {
main.java.srcDirs += 'src/main/lib/sweetblue/library/src/main/java'
main.res.srcDirs += 'src/main/lib/sweetblue/library/src/main/res'
...
}
...
}
``````
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 18
targetSdkVersion 25
...
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
...
}
...
}
```Now add these to the root of MyApp/AndroidManifest.xml:
From your Activity or Service or Application instance, this is all it takes to discover a device, connect to it, and read a characteristic:
…SweetBlue is released here under the GPLv3. Please visit https://sweetblue.io for SweetBlue v3, as v2 is no longer licensable for commercial applications. In a nutshell, if you're developing a for-profit commercial app you may use this library for free for evaluation purposes, but most likely your use case will require purchasing a proprietary license before you can release your app to the public. See the FAQ for more details and https://tldrlegal.com/license/gnu-general-public-license-v3-%28gpl-3%29 for a general overview of the GPL.
No open issues yet, or sync has not completed.