Import Library project:
- Open your project in Android Studio
- Download the library (using Git, or a zip archive to unzip)
- Go to File > Import Module and import the library as a module
- Go to File > Project Structure > Modules
- Locate your main project module, click on it. It should have a few android libraries such as support-v4 etc.
- Click on the more on the left green "+" button > Module dependency
- Select "Freemium Library" (not Freemium Library Project)
Google map implementation flow:
http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html
http://www.tutorialspoint.com/android/android_google_maps.htm
Which plugin need to use in build.gradel :
In projLib's build.gradle file, you'll see a statement like this:
apply plugin: 'com.android.application'
which tells Gradle to build it as an application, generating an APK. If you change it to this:
apply plugin: 'com.android.library'
it will build as a library, generating an AAR, and it should work.
If you also need projLib to generate a separate APK, then you'll have to do some refactoring to pull the common code that you need out into a third library module, and have both APKs depend on it.
Libraries aren't allowed to set an
applicationId
, so if you see an error message to that effect, remove it from the library's build script.
And Importantly for maintaining the code for build.gradel in AndroidStudio :
/app/build.gradel :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.cartravels" minSdkVersion 9 targetSdkVersion 19 }
buildTypes {
release {
minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt }
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0' compile project(':libraries:google-play-services_lib')
}
/libraries/google-play-services_lib/build.gradel :
apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'}
repositories {
mavenCentral()
}
android {
compileSdkVersion 22 buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 9 targetSdkVersion 19 }
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
CarTravels/build.gradel :
// 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' }
}
allprojects {
repositories {
jcenter()
}
}
CarTravels/settings.gradel :
include ':app'include ':libraries:google-play-services_lib'
Comments
Post a Comment