I'm a newbie in Android especially for libs.
I'm using Android Studio 1.2.2
I'm trying to create a jar library with no activity, resources, etc (only code) that use the AltBeacon library. When complete I whould like to include this jar in my APP that has to use beacons through my lib.
Well, using AltBeacon instructions, I'm able configure gradle to have a "normal" (with activity etc) APP using AltBeacon library. But I'm not able to create a jar library that contains the AltBeacon one. I google a lot especially in SO, I found a lot of questions about "library inside library" but that doesn't worked for me.
I made this:
- I created an empty project with Studio (blank activity)
- Then I created a new module -> Java Library and called it libmebeaconmanager and Studio created a new Java class that I called MeBeaconManager
I modified the build.gradle of the library in this way:
apply plugin: 'java'
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'org.altbeacon:android-beacon-library:2+'
}
This is the build.gradle of Module:app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "me.padovame.libbeacontest"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
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.2.0'
}
And this is the build.gradle of project:
// 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.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
At this point, in the MeBeaconManager class of the lib, I tried to import AltBeacon classes without success because I got an undefined symbol error for import lines like this:
import org.altbeacon.beacon.Beacon;
I also tried, without success, inserting in lib folder of libmebeaconmanager the downloaded android-beacon-library-2.3.aar
What am I doing wrong?
Thanks in advance.
EDIT: I tried to include a jar (tried with Picasso) library in my libmebeaconmanager and it worked. So the problem seems to be with aar libs.
I'm going crazy...
EDIT 2: I extracted classes.jar from the AltBeacon aar lib and used as other jar and it worked.
But I consider this as a workaround: I still do not understand how to manage directly aar files. So thanks to whom can help me.