Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Painless Libraries - Londroid April 2019
Search
Sérgio Marques Moura
April 16, 2019
Programming
130
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Painless Libraries - Londroid April 2019
Sérgio Marques Moura
April 16, 2019
More Decks by Sérgio Marques Moura
See All by Sérgio Marques Moura
Go Native: Integrating Native Code on Android
sergiomarquesmoura
0
31
AndroidLX: From an app to a library
sergiomarquesmoura
2
51
Android Lx - 25 Jan 2017 - RxJava: More than the basic
sergiomarquesmoura
0
96
AndKotlin
sergiomarquesmoura
0
42
Other Decks in Programming
See All in Programming
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
130
Heart of Swift Concurrency
koher
0
1k
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
300
MCP Appsでつくるチャット駆動な地図アプリ
nakamori1024
0
110
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
270
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
170
Security issues being discussed on Web Platforms
petamoriken
0
1.3k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
550
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
280
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
440
setup-vp GitLab対応の裏側
naokihaba
0
140
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.1k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
211
25k
Deep Space Network (abreviated)
tonyrice
0
320
Believing is Seeing
oripsolob
1
230
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
Writing Fast Ruby
sferik
630
63k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
700
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Transcript
@sergiomarqmoura
Who here develops Android libraries…?
Who here develops Android libraries...to be used by external applications?
onfido-android-sdk ├── build.gradle ├── gradle.properties ├── proguard-rules.pro ├── src ├──
main │ ├── AndroidManifest.xml │ ├── java │ └── res └── test
onfido-android-sdk └── build.gradle
onfido-android-sdk └── build.gradle ├── resources name prefix
onfido-android-sdk └── src ├── main └── res ├── drawable ├──
logo.xml ├── layout ├── activity_camera.xml app └── src ├── main └── res ├── drawable ├── logo.xml ├── layout ├── activity_camera.xml
onfido-android-sdk app logo.xml logo.xml <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo"/>
onfido-android-sdk app activity_camera.xml activity_camera.xml <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.onfido.android.sdk.capture.ui.camera.CameraView android:id="@+id/cameraView"
android:layout_width="match_parent" android:layout_height="match_parent"/> ... </androidx.coordinatorlayout.widget.CoordinatorLayout> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo"/> ... </androidx.coordinatorlayout.widget.CoordinatorLayout> import kotlinx.android.synthetic.main.activity_camera.* cameraView.start() java.lang.NoSuchFieldError: com.onfido.android.sdk.capture.R$id.cameraView
• android { /* Enables IDE warning if non-prefixed resource
is defined. Code still compiles. Allowed names: - onfidoResource - onfido_resource - OnfidoResource */ resourcePrefix 'onfido' } • lintOptions { lintConfig rootProject.file("lint-rules.xml") abortOnError true } lint-rules-xml <lint> <issue id="ResourceName" severity="error" /> ... <issue id="NewApi" severity="warning" /> <issue id="MissingTranslation" severity="warning" /> </lint> ./gradlew onfido-android-sdk:lint
onfido-android-sdk └── build.gradle ├── bundled Proguard rules ├── resources name
prefix ├── size impact
• ◦ ◦ ▪ ◦ ▪ ▪ dependencies { implementation
"com.onfido.sdk.capture:onfido-capture-sdk:4.8.0" } ./gradlew app:assembleRelease; ls -lh app/build/outputs/apk/release/
• ◦ ◦ // host application build.gradle splits { abi
{ enable true reset() include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' universalApk true //generate an additional APK that contains all the ABIs } } AndroidX build artifacts androidx.core:core:1.0.0 androidx.recyclerview:recyclerview:1.0.0 androidx.constraintlayout:constraintlayout:1.0.0 androidx.lifecycle:lifecycle-livedata:1.0.0 dependencies { implementation 'com.onfido.sdk.capture:onfido-capture-sdk:4.8.0' // OR implementation 'com.onfido.sdk.capture:onfido-capture-sdk-core:4.8.0' (-48% size) }
onfido-android-sdk └── build.gradle ├── bundled Proguard rules ├── resources name
prefix ├── size impact ├── dependencies
• // library implementation 'com.onfido:sample-lib:4.0.0' // app implementation 'com.onfido:sample-lib:4.0.0' ◦
▪ ◦ ▪ ▪ // library implementation 'com.onfido:sample-lib:4.0.0' // app implementation 'com.onfido:sample-lib:3.0.0'
• // library implementation 'com.google.dagger:dagger:2.22' // app implementation 'com.squareup:dagger:1.2.5' com.android.build.api.transform.TransformException:
com.android.dex.DexException: Multiple dex files define Ldagger/MembersInjector • •
class MyApplication : Application() { override fun onCreate() { super.onCreate()
AnalyticsLib.init(this, "APP_TOKEN") SampleLib.init(this) } } • class SampleLib { companion object { @JvmStatic fun init(context: Context) { AnalyticsLib.init(context, "LIBRARY_TOKEN") } } } • AnalyticsLib • AnalyticsLib • AnalyticsLib fun track(eventName: String) { AnalyticsLib.getInstance().track(eventName) }
• ◦ com.samplelib.AnalyticsLib -> com.onfido.samplelib.AnalyticsLib com.samplelib.AnalyticsLib.init(context, "TOKEN") =/= com.onfido.samplelib.AnalyticsLib.init(context, "TOKEN")
◦ ◦ buildscript { dependencies { classpath 'ru.tinkoff.gradle:jarjar:1.1.0' classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.1' } } apply plugin: 'ru.tinkoff.gradle.jarjar' apply plugin: 'com.github.johnrengelman.shadow'
jarJar { rules = [ “analyticsLib-$version.jar” : 'com.samplelib.** com.onfido.samplelib.@1' ]
} dependencies { jarJar "com.samplelib:analytics:$version" implementation files("build/libs/analytics-$version.jar") } ◦ ◦ $version LICENSE.md
onfido-android-sdk ├── build.gradle │ ├── bundled Proguard rules │ ├──
resources name prefix │ ├── size impact │ ├── dependencies ├── src │ ├── main │ │ ├── AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.onfido.android.sdk.capture"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" /> <application>
<activity android:name=".ui.OnfidoActivity" android:label="@string/onfido_activity_label" android:theme="@style/OnfidoActivityTheme" /> </application> </manifest> java.lang.IllegalArgumentException: either category or name must be provided.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.onfido.android.sdk.capture"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" /> <application>
<provider android:name=".OnfidoInitProvider" android:authorities="${applicationId}.onfidoinitprovider" android:enabled="true" android:exported="false"/> <activity android:name=".ui.OnfidoActivity" android:label="@string/onfido_activity_label" android:theme="@style/OnfidoActivityTheme" /> </application> </manifest>
class MyApplication : Application() { override fun onCreate() { super.onCreate()
SampleLib.init(this) } } class OnfidoInitProvider extends ContentProvider { override fun onCreate(): Boolean { SampleLib.init(context); return false; } } • ◦ ◦ • ◦ ◦
onfido-android-sdk ├── build.gradle │ ├── bundled Proguard rules │ ├──
resources name prefix │ ├── size impact │ ├── dependencies ├── src │ ├── main │ │ ├── AndroidManifest.xml ├── java ├── res
• google-services.json ❖ firebase-auth ❖ firebase-messaging ❖ firebase-* { "project_info":
{ "project_number": "PROJECT_NUMBER", "firebase_url": "FIREBASE_URL", "project_id": "PROJECT_ID", "storage_bucket": "STORAGE_BUCKET" }, "client": [ { "client_info": { "mobilesdk_app_id": "MOBILE_SDK_APP_ID", "android_client_info": { "package_name": "PACKAGE_NAME" } }, "api_key": [ { "current_key": "KEY" } ], "services": { "analytics_service": { "status": 1 } } } ], "configuration_version": "CONFIGURATION_VERSION" } <string name="google_api_key">API_KEY</string> <string name="google_app_id">APPLICATION_ID</string> <string name="google_storage_bucket">STORAGE_BUCKET</string> <string name="firebase_database_url">FIREBASE_URL</string> <string name="project_id">PROJECT_ID</string> try { FirebaseApp.initializeApp(context, FirebaseOptions.Builder() .setApiKey("API_KEY") .setApplicationId("APPLICATION_ID") .build(), "PACKAGE_NAME") } catch (e: IllegalStateException) { // fallback code }
Thank you! Q&A