Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Yuliya Kaleda] Make Your App Instant!

[Yuliya Kaleda] Make Your App Instant!

Presentation from GDG DevFest Ukraine 2017 - the biggest community-driven Google tech conference in the CEE.

Learn more at: https://devfest.gdg.org.ua

Google Developers Group Lviv

October 14, 2017
Tweet

More Decks by Google Developers Group Lviv

Other Decks in Technology

Transcript

  1. Best of Two Worlds Instant Apps mWeb native material design

    navigation installation space friendly @YuliyaKaleda
  2. <activity android:name="com.jet.cartlib.activities.CartActivity" android:launchMode="singleTop" android:parentActivityName=".activities.RootActivity" android:windowSoftInputMode="adjustResize|adjustPan"> <intent-filter android:order="2"> <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="www.jet.com" /> <data android:host="jet.com" /> <data android:pathPrefix="/cart" /> </intent-filter> </activity> AndroidManifest.xml
  3. AndroidManifest.xml <activity android:name="com.jet.cartlib.activities.CartActivity" android:launchMode="singleTop" android:parentActivityName=".activities.RootActivity" android:windowSoftInputMode="adjustResize|adjustPan"> <intent-filter android:order="2"> <action android:name="android.intent.action.VIEW"

    /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="www.jet.com" /> <data android:host="jet.com" /> <data android:pathPrefix="/cart" /> </intent-filter> </activity>
  4. AndroidManifest.xml <activity android:name="com.jet.cartlib.activities.CartActivity" android:launchMode="singleTop" android:parentActivityName=".activities.RootActivity" android:windowSoftInputMode="adjustResize|adjustPan"> <intent-filter android:order="2"> <action android:name="android.intent.action.VIEW"

    /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="www.jet.com" /> <data android:host="jet.com" /> <data android:pathPrefix="/cart" /> </intent-filter> </activity>
  5. base/build.gradle apply plugin: 'com.android.feature' apply plugin: 'io.fabric' apply plugin: 'newrelic'

    android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName vectorDrawables.useSupportLibrary = true baseFeature true … } dependencies { //lib dependencies api 'com.squareup.picasso:picasso:2.5.2' }
  6. app/build.gradle apply plugin: 'com.android.application' apply plugin: 'io.fabric' apply plugin: 'newrelic'

    android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName vectorDrawables.useSupportLibrary = true … } dependencies { implementation project(':baselib') }
  7. instantApp/build.gradle apply plugin: ‘com.android.instantapp' apply plugin: 'io.fabric' apply plugin: 'newrelic'

    android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName … } dependencies { implementation project(':baselib') }
  8. Multi-Feature Instant Apps app module d { c o }

    e feature modules @YuliyaKaleda
  9. Multi-Feature Instant Apps PLP product list page PDP product detail

    page Cart ODP order detail page @YuliyaKaleda
  10. Multi-Feature Instant Apps app module d { c o }

    e base module instant app module @YuliyaKaleda
  11. base/build.gradle apply plugin: 'com.android.feature' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion

    defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion vectorDrawables.useSupportLibrary = true baseFeature true } dependencies { feature project(':plplib') feature project(':pdplib') feature project(':cartlib') feature project(':orderDetailLib') application project(':app') //lib dependencies api 'com.squareup.picasso:picasso:2.5.2' }
  12. base/build.gradle apply plugin: 'com.android.feature' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion

    defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion vectorDrawables.useSupportLibrary = true baseFeature true } dependencies { feature project(':plplib') feature project(':pdplib') feature project(':cartlib') feature project(':orderDetailLib') application project(':app') //lib dependencies api 'com.squareup.picasso:picasso:2.5.2' }
  13. feature/build.gradle apply plugin: 'com.android.feature' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion

    defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName } dependencies { implementation project(':baselib') }
  14. app/build.gradle apply plugin: 'com.android.application' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion

    defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName } dependencies { implementation project(':baselib') implementation project(':plplib') implementation project(':pdplib') implementation project(':cartlib') implementation project(':orderDetailLib') }
  15. instantApp/build.gradle apply plugin: ‘com.android.instantapp' android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion

    defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode rootProject.versionCode versionName rootProject.versionName } dependencies { implementation project(':baselib') implementation project(':plplib') implementation project(':pdplib') implementation project(':cartlib') implementation project(':orderDetailLib') }
  16. Slim down your app • Review dependencies • Enable Proguard

    • Shrink resources • Use vector drawables • PNG -> WebP X MB 4 MB
  17. Instant Apps API override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_no_network)

    val addPaymentButton = findViewById(R.id.add_new_payment) as Button if (InstantApps.isInstantApp(this)) { addPaymentButton.visibility = View.GONE } }
  18. Version code and name Failure [INSTALL_FAILED_INVALID_APK: /data/app/ vmdl894193015.tmp/7_pdplib-app-instantApp.apk version code

    0 inconsistent with 494] android { defaultConfig { versionCode rootProject.versionCode versionName rootProject.versionName } }
  19. Proguard java.lang.NoSuchMethodError: No static method setCompatVectorFromResourcesEnabled(Z)V in class Landroid/support/v7/app/AppCompatDelegate; or

    its super classes (declaration of 'android.support.v7.app.AppCompatDelegate' appears in / data/app/com.jet.jet.staging-IIohNI4xXzrcQ1tt01ksgA==/ base.apk) -keep class android.support.v7.app.AppCompatDelegate { *; }
  20. Resources Task :cartlib:compileAppInstantAppFeatureJavaWithJavac /Users/yuliya/Desktop/jetApp/batman-android/cartlib/src/ main/java/com/jet/cartlib/mvp/cart/CartListFragment.java: 568: error: cannot find symbol

    Toolbar toolbar = findViewById(R.id.toolbar); ^ symbol: variable toolbar location: class id Toolbar toolbar = findViewById(com.jet.baselib.R.id.toolbar);
  21. Reusable Layouts in feature modules <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=“http://schemas.android.com/tools"> <include layout="@layout/view_toolbar"

    /> <TextView android:id="@+id/checkout_initial_breadcrumb_status" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp" tools:text="Shipping>Payment>Review" /> </merge>
  22. Benefits • size reduction • modularization • code clean up

    • new features (Smart Lock, Google Payments) • conversion rate +27% • cart size +7% @YuliyaKaleda