package com.emil.android.util; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.telephony.TelephonyManager; | |
/** | |
* Check device's network connectivity and speed | |
* @author emil http://stackoverflow.com/users/220710/emil |
import android.app.Activity; | |
import android.app.Service; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.os.Bundle; | |
import android.os.IBinder; | |
import android.support.v4.content.LocalBroadcastManager; |
So we're working on creating Android Material Awesome, a library which will hopefully incorperate the benefits of Material Design, Twitter's Bootstrap, and FontAwesome. What we really wanted is a project other people can easily include into their projects using gradle dependencies. To do this we needed to create a standalone library project so we could make it as lightweight as possible for including as a dependency, and a sample app that would use it for testing. These are the steps we took to get started in Android Studio (version 1.1).
The first thing we needed to do was to create two new projects, with all the default settings (Blank Activity etc). One for our sample app, and one for our library. We added both of ours into the same GitHub repo, however you can save them wherever you like.
apply plugin: 'com.jfrog.bintray' | |
version = libraryVersion | |
task sourcesJar(type: Jar) { | |
from sourceSets.main.allSource | |
classifier = 'sources' | |
} | |
task javadocJar(type: Jar, dependsOn: javadoc) { |
apply plugin: 'com.jfrog.bintray' | |
version = libraryVersion | |
task sourcesJar(type: Jar) { | |
from android.sourceSets.main.java.srcDirs | |
classifier = 'sources' | |
} | |
task javadoc(type: Javadoc) { |
apply plugin: 'com.github.dcendents.android-maven' | |
group = publishedGroupId // Maven Group ID for the artifact | |
install { | |
repositories.mavenInstaller { | |
// This generates POM.xml with proper parameters | |
pom { | |
project { | |
packaging 'aar' |
Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:
-
I use "Android Studio" and I have this simple android lib that I would like to be available on maven: CircularImageView
-
In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder
apply plugin: 'com.android.library'
I got as output an .aar in the build/outputs/aar/ directory of the module's directory
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.