I am facing some questions on android-support-v4.jar now a days.
What is android-support-v4.jar
What will happen if we remove android-support-v4.jar from \libs folder
Which class files are there in android-support-v4.jar
What is exact usage of android-support-v4.jar in Android
It is the Support Library for Android that provides backward compatibility for developers to use new API Level features in mobiles that doesn't provide that feature. Hence using Support Library you can broaden the range of targeted mobile devices.
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. Each
Support Library is backward-compatible to a specific Android API
level. This design means that your applications can use the libraries'
features and still be compatible with devices running Android 1.6 (API
level 4) and up.
You app or atleast some of the features will not work on Android Devices with Older API levels like Honeycomb or Freyo.
You can see all the classes in android-support-v4.jar here.
Eg: Including Support Library you can use ViewPager in API Level 8 which is Freyo.
You can know everything about android-support-v4.jar here.
Related
I am going to build a new app, targeting API21 and higher, do I need AppCompat v7 or I can omit it?
It depends on what features you want to implement and which functionalities you want to develop. Targeting API level and minimum API level are both different thing. Your selection of support libraries depends upon your your minimum API level, that is defined by minSdkVersion.
You can decide and derive below conclusion from official Android Developer Documentation:
v4 Support Library
This library is designed to be used with Android 2.3 (API level 9) and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities.
v7 Libraries
There are several libraries designed to be used with Android 2.3 (API level 9) and higher. These libraries provide specific feature sets and can be included in your application independently from each other.
v7 AppCompat library
This library adds support for the Action Bar user interface design pattern.
Note: This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.
v13 Support Library
This library is designed to be used for Android 3.2 (API level 13) and higher. It adds support for the Fragment user interface pattern with the (FragmentCompat) class and additional fragment support classes.
I used the above mentioned widget in my XML. However, I'm just seeing a normal list view and not a recycler view on android 5.1. Wanted to understand if the above mentioned widget is specific to a particular OS version?
From the documentation on Android Support Libraries:
Some of the Support Library packages have package names to indicate
the minimum level of the API they originally supported, using a v#
notation, such as the support-v4 package. Starting with Support
Library version 26.0.0 (released in July 2017), the minimum supported
API level has changed to Android 4.0 (API level 14) for all support
library packages. For this reason, when working with any recent
release of the support library, you should not assume that the the v#
package notation indicates a minimum API support level. This change in
recent releases also means that library packages with the v4 and v7
are essentially equivalent in the minimum level of API they support.
For example, the support-v4 and the support-v7 package both support a
minimum API level of 14, for releases of the Support Library from
26.0.0 and higher.
v7 is just part of the package name, and refers to the version of the support library your project is using. There was an earlier version (v4), which was used with API version 4 or less (Android 1.6). Version 7 support library was a later version of the support library, which worked with newer versions of Android, and introduced new features.
Some information about it here
http://developer.android.com/tools/support-library/features.html
No this denotes the version of Android Libraries.
These libraries provide specific feature sets and can be included in
your application independently from each other.
Read more here
I'm just seeing a normal ListView
Well a Recycler View is a modification to the classical ListView. In the Layout Editor it appears like that only.
I am new to android app development.I don't understand what the android support library is?.Is it included in android framework APIs like API level 17,18 or is it separate API which can be included in projects.Thanks in advance!!
Is it included in android framework APIs like API level 17,18
No.
or is it separate API which can be included in projects
Yes.
Quoting the documentation:
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. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up.
When I want to create an Android app that can use the recent supported features of Android, I use libraries like:
appcompat_v7
support_v4
What I haven't been able to determine is what is the earliest version of Android that an appcompat_xxx or support library can actually support. Where do I find this information?
It's all in the name - appcompat_v7 supports API 7 and later, support_v4 supports API 4 and later.
It's also clearly stated in the docs for each library, for example:
This library is designed to be used with Android 1.6 (API level 4)
and higher.
http://developer.android.com/tools/support-library/features.html#v4
Also, although this isn't always required, you should try to match up your targetSdkVersion with the respective version of the library. For example, if your targetSdkVersion is 19, you should use com.android.support:appcompat-v7:19.+
To be clear: the support libraries, as dictated by their name, are designed to support a minimum API level. Meaning - they can be safely used on devices running that API level, as well as devices on any later API level. If you attempt to use appcompat_v7 on a donut device (API level 4), or the leanback-v17 library on a Jellybean 4.1 device (API level 16), your app will likely crash with something like a ClassNotFoundException.
The libraries were originally supposed to provide the functionality of newer API levels to the older API levels, such that you could write nearly the same code and leverage the latest platform paradigms in a single APK that would support old and new devices.
Fragments are a perfect example of this. The Fragment class was introduced with Honeycomb (API level 11). Google then released the support_v4 library which contained a back-ported version of the Fragment class and it's respective APIs. Again, as dictated by it's name, this library could be safely used in an app that supports all the way back to API 4. If you install an app using the v4 library on a API 3 device, it will crash. If you install it on, say, an API 8 device, it will work as intended.
Perhaps you're getting caught up on the seemingly delicate nature of relying on a file name to specify the min sdk version - now this is a bit of a guess, but when the v4 library was first introduced, it was just a .jar file. Meaning, you could add it to your app's classpath, no matter what minSdkVersion you use, and it would compile without complaining. MY guess is that Google wanted to explicitly name these libraries using their minimum SDK version to avoid developers trying to use them in apps that are meant to support early API versions. Aside from their docs, which again very explicitly answer your question, the filename was perhaps was a risk mitigating approach to help developers who don't read the docs.
Fast forward to 2014, many of these libraries either come in the form of .aar files (via Gradle), or you need to import them as projects. This is because these libraries now include resources such as images and themes, which cannot be packaged into a .jar file. An added benefit here is that this allows Google to include an AndroidManifest.xml with the library which specifies a minSdkVersion. At compile time, the build tools' manifest merger will complain if your minSdkVersion is lower than the minSdkVersion specified in any included library projects.
I'm trying to implement cursor loaders into my android app. When I write the code for LoaderManagers, eclipse prompts me to import the correct libraries. However there are two options which appear to be the same; android.app and android.support.v4.app. Whats the difference between these two, and which one should I use?
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. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up.
This both are different library android.app is for the i.e. Fragment which are available from the API level 3.0 and above. So to use the Fragments in below api's you have to use its backword compatible libraries form android.support.v4.app to support below the API level than 3.0. So android has provided the flexibility to provide the support in lower version using android.support.v4.app library.
Each Support Library is backward-compatible to a specific Android API level. So whenever you are implmenting anything which is available in 3.0 but not below then you should use its support library.