RadiusNetwork's Android iBeacon Library
-
21-12-2019 - |
Question
I'm trying to use the Android IBeacon Library in my application. I have added all dependencies in my gradle file and gradle sync fails with the following error:
Failed to refresh Gradle project 'IBeaconTest'
Could not find com.radiusnetworks:AndroidIBeaconLibrary:0.7.6.
Required by:
IBeaconTest:ibeacon:1.0
This is my project's structure:
Update 1:
Module's build.gradle file(IbeaconTest/ibeacon/build.gradle):
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 18
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.6@aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Main project's build.gradle(IBeaconTest/build.gradle):
buildscript {
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Solution
Try putting the flatDir
configuration in your module's build.gradle file.
Like this:
Module's build.gradle file(IbeaconTest/ibeacon/build.gradle):
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 18
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7+@aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
OTHER TIPS
You're going through more work than necessary to include the library. From their quick start (http://developer.radiusnetworks.com/ibeacon/android/configure.html), you can use the library in Android Studio by doing this:
- Download the AAR file (http://developer.radiusnetworks.com/ibeacon/android/download.html)
- Create a /libs directory inside your module directory and copy the AAR file there.
Edit your build.gradle file, and add a "flatDir" entry to your repositories like so:
repositories { mavenCentral() flatDir { dirs 'libs' } }
Edit your build.gradle file to add this AAR as a dependency like so:
dependencies { compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.1@aar' }
Follow these instructions instead of including it as a library project like you have.
The way you're currently doing it, when including the library as a project, that error is happening because it's expecting sonatypeRepo
to be set to a URL for the Maven repository, but it's not defined anywhere. But if you follow their instructions for adding the library, you shouldn't have to worry about it.