I have integrated Twitter and all is done well.
But now I need to create a reusable component.
Ie: a library using the fabric sdk in android studio.
We can get the fabric plugin from the Twitter developer site.
By using that I'm able to add sdk to an Android Studio project, but not to a library.
How to add this sdk to an Android Studio library project?
Define the classpath in your project's build.gradle
as usual.
Add the dependencies to your library module as you would suspect.
Apply the io.fabric
plugin in your app module. No way around this, that's by design. Fabric needs application ID, libraries don't have one.
EDIT: Due to manifest merging you are able to specify the API key meta-data (eg for Crashlytics) in your library's manifest.
EDIT 2: Looks like there's a page for it. http://support.crashlytics.com/knowledgebase/articles/456258-library-subproject-in-gradle https://docs.fabric.io/android/crashlytics/build-tools.html#set-up-a-library-subproject
For creating reusable component with fabric sdk.update your gradle to something like this
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
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.0.0'
compile('com.twitter.sdk.android:twitter:1.3.2@aar') {
transitive = true;
}
}
Do rebuild your project after updating gradle file.you wil get the skd access now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.