Support Library? The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. — Android Developers 5 DroidKaigi 2016
Chronicle-1 The release date of android OS and the number of Support Library1 1 Reference: Android developers - API Levels and Android version history. 6 DroidKaigi 2016
What can we do? 1. We can better implementation. (Not the best) • e.g. Use of RxJava 2. We can easily implement a user interface that Google is recommended. • e.g. Implementation of Material design 12 DroidKaigi 2016
V series • v4 Support Library • v7 Support Library • v8 Support Library • v13 Support Library • v14 Preference Support Library • v17 Preference Support Library • v17 Leanback Library 14 DroidKaigi 2016
v4 Support Library • Android 1.6 (API level 4) and higher • With the biggest API set in Support Library • Without resouces dependencies { compile 'com.android.support:support-v4:23.1.1' } 15 DroidKaigi 2016
Helpful class Many class named ʙCompat Helper for accessing features in [name of class] introduced after API level 4 in a backwards compatible fashion. 21 DroidKaigi 2016
Example: NotificationCompat Helper for accessing features in Notification introduced after API level 4 in a backwards compatible fashion. — NotificationCompat - Class overview 22 DroidKaigi 2016
v7-appcompat • Depend on v4-support. • Support for material design user interface implementations. dependencies { compile 'com.android.support:appcompat-v7:23.1.1' } 27 DroidKaigi 2016
i.e. depend on v4-support $ gradle -q dependencies app:dependencies ------------------------------------------------------------ Root project ------------------------------------------------------------ No configurations ------------------------------------------------------------ Project :app - Injects the build id used by the Fabric SDK. ------------------------------------------------------------ _debugCompile - ## Internal use, do not manually configure ## +--- com.android.support:appcompat-v7:23.0.1 (*) | +--- com.android.support:support-v4:23.0.1 (*) ... 28 DroidKaigi 2016
i.e support for material design implementations e.g. AlertDialog // v7-appcompat new android.support.v7.app.AlertDialog.Builder(context) .setTitle("Hi!") .setMessage("Welcome to DroidKaigi 2016.") .setNegativeButton("close", null) .show(); // android.app new AlertDialog.Builder(context) .setTitle("Hi!") .setMessage("Welcome to DroidKaigi 2016.") .setNegativeButton("close", null) .show(); 29 DroidKaigi 2016
v7-recyclerview • There is also a case to replace the ListView of ViewHolder pattern. • It increases the degree of freedom in the display of the List format. dependencies { compile 'com.android.support:recyclerview-v7:23.1.1' } 31 DroidKaigi 2016
Other v7: palette • Add the Palette class which lets you extract prominent colors from an image. dependencies { compile 'com.android.support:palette-v7:23.1.1' } 36 DroidKaigi 2016
Other v7: mediarouter • Provide MediaRouter and MediaRouteProvider class. • Google recommend using the library only in connection with Google Cast. dependencies { compile 'com.android.support:mediarouter-v7:23.1.1' } 38 DroidKaigi 2016
What is the RenderScript?3 • High-speed drawing processing using GPU. • Not tied to a machine-architectures like AndroidNDK. 3 Reference: Android Developers - RenderScript. 40 DroidKaigi 2016
v13 Support Library • Android 3.2 (API level 13) and higher • Support for using the ViewPager with "android.app.Fragment". dependencies { compile 'com.android.support:support-v13:23.1.1' } 41 DroidKaigi 2016
v14 Preference Support Library • Support for PreferenceFragment using "android.app.Fragment". dependencies { compile 'com.android.support:preference-v14:23.1.1' } 42 DroidKaigi 2016
v17 Preference Support Library • Provide preference interfaces on TV devices dependencies { compile 'com.android.support:preference-leanback-v17:23.1.1' } 43 DroidKaigi 2016
v17 Leanback Library • Support for use the UI widgets for TV apps. • Provide the theme of Theme.Leanback. • Depend on v4-support and v7-recyclerview. dependencies { compile 'com.android.support:leanback-v17:23.1.1' } 45 DroidKaigi 2016
Demo: androidtv-leanbackGitHub For me all access to local network and internet do not work with android tv emulator sdk 22 and 23. — Playback/Streaming does not work. #50 GitHub https:/ /github.com/googlesamples/androidtv-Leanback 47 DroidKaigi 2016
Speciality series • Multidex Support Library • Annotations Support Library • Design Support Library • Custom Tabs Support Library • Percent Support Library • Recommendation Support Library for TV 50 DroidKaigi 2016
What case does multidex need? If you get in such a build error... Conversion to Dalvik format failed: Unable to excute dex: method ID not in [0, 0xffff]: 65536 52 DroidKaigi 2016
What case does multidex need? Or that's recently... trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option. 53 DroidKaigi 2016
Optimizing multidex development builds For the development flavor, set a minimum SDK version of 21. This setting generates multidex output much faster using the ART-supported format. For the release flavor, set a minimum SDK version which matches your actual minimum support level. — from Android Developers 55 DroidKaigi 2016
Build configuration sample android { productFlavors { // Define separate dev and prod product flavors. dev { // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin // to pre-dex each module and produce an APK that can be tested on // Android Lollipop without time consuming dex merging processes. minSdkVersion 21 } prod { // The actual minSdkVersion for the application. minSdkVersion 14 } } ... buildTypes { release { runProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile 'com.android.support:multidex:1.0.0' } 56 DroidKaigi 2016
What happens when you create the multidex app?4 $ unzip app-debug.apk extracting: ... inflating: ... $ ls AndroidManifest.xml app-normal-debug.apk classes.dex lib res META-INF assets classes2.dex org resources.arsc $ ls *.dex classes.dex classes2.dex 4 Reference to Building Apps with Over 65K Methods 57 DroidKaigi 2016
Annotations Support Library • Support for annotation metadata. • With resouces dependencies { compile 'com.android.support:support-annotations:23.1.1' } 58 DroidKaigi 2016
Design Support Library • Support for material design components and patterns. • With resouces dependencies { compile 'com.android.support:design:23.1.1' } 61 DroidKaigi 2016
Animation of FAB FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); // Set custom behavior class params.setBehavior(new ScrollingFabBehavior()); 69 DroidKaigi 2016
Custom Tabs Support Library • Support for managing CustomTabs. • With resouces dependencies { compile 'com.android.support:customtabs:23.1.1' } 70 DroidKaigi 2016
Custom Tabs?5 Chrome Custom Tabs allow an app to customize how Chrome looks and feels. — from official site 5 CustomTabs's oficial site: Chrome Custom Tabs 71 DroidKaigi 2016
How to open the page with CustomTabs CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() // customize toolbar's color .setToolbarColor(getResources().getColor(R.color.colorPrimary)) .build(); // use shared project String packageName = CustomTabsHelper.getPackageNameToUse(MainActivity.this); customTabsIntent.intent.setPackage(packageName); customTabsIntent.launchUrl(MainActivity.this, Uri.parse("http://zaim.net/")); 74 DroidKaigi 2016
Percent Support Library • Support for managing percentage based dimmentions. • With resouces dependencies { compile 'com.android.support:percent:23.1.1' } 75 DroidKaigi 2016
Recommendation Support Library for TV • Content catalog in the TV home screen. • With resouces dependencies { compile 'com.android.support:recommendation:23.1.1' } 78 DroidKaigi 2016