'android.app.Notification$Builder' Class not found - android

Background
I'm working to make my app supporting 2.3.3 version (Api level 10), but i got the below error.
Log
Could not find class 'android.app.Notification$Builder', referenced from method
com.google.android.gms.common.GooglePlayServicesUtil.showErrorNotification

Notification.Builder was added in API level 11. For earlier versions, NotificationCompat.Builder should be used instead.
Since the error comes from Google Play Services, use google_play_services_froyo instead of google_play_services for pre-11 targets.

Related

Conditionally use library

I want to add flutter_sound_lite to my application, Currently my Android API level is 16 and iOS target is 9.0
Flutter Sound requires an iOS 10.0 SDK and Android API level 21
I want to keep my API level (16) and iOS target(9.0), and add Flutter Sound too, just don't use it on old devices, How can I do it?
For android I add the following line in manifest
<uses-sdk tools:overrideLibrary="com.dooboolab.fluttersound, com.dooboolab.TauEngine" />
But in android log cat I have error
04-17 10:27:08.182 2973-2973/ir.karget E/dalvikvm: Could not find class 'android.media.AudioAttributes$Builder', referenced from method androidx.core.app.NotificationCompat$Builder.setSound

ArraySet in android.util and android.support.v4.util

What is the difference between
android.util.ArraySet
android.support.v4.util.ArraySet
All methods seem to be identical.
As the page indicates, android.util.ArraySet was added in API level 23. android.support.v4.util.ArraySet is a copy in the backwards-compatibility support library, which allows you to use the class on older devices as far back as API level 4 (increased to level 14 in recent releases).

Compatibility for Java library methods that require Android API level 9?

Some Java library methods like DecimalFormat.setRoundingMode have a #since 1.6 entry in their documentation.
/**
...
* #since 1.6
*/
public void setRoundingMode(RoundingMode roundingMode) {
...
}
When I tried to use this method compiled under Android 4.2.2 and JDK 1.6 with my android:minSdkVersion set to 7 as shown,
myNumberFormat.setRoundingMode(RoundingMode.DOWN);
Android Lint underlined setRoundingMode in red for me and told me that
Call requires API level 9 (current min is 7): java.text.NumberFormat#setRoundingMode
How and why can the Android API restrict which Java library methods I can and cannot use? I cleaned my project and the Lint error disappeared. My project compiled with no errors and ran on a device running Android 2.2.3 (API 8).
My program crashed with:
05-09 11:32:38.436: E/AndroidRuntime(2074): Caused by: java.lang.NoSuchMethodError: java.text.NumberFormat.setRoundingMode
The Android documentation confirms that setRoundingMode, copySign, and others were added in API level 9. Does that mean that devices running Android OS level 8 and below are specifically compiled/built with JDK 1.5?
And I can understand that. But is it impossible for the Android Support Library (or anything else) to allow us to use these methods?
Related to Rounding Half Up with Decimal Format in Android

getLoaderManager.initLoader() can't be resolved under API level 10 in Android

in Android :
I want to use the method : getLoaderManager.initLoader() with API level 10 .
I know that this method requires API Level 11 or higher and i tried to use Android Support package but this package doesn't have this method .
what can i do ??
It sure looks to me like the Android Support Package has it. See the docs for android.support.v4.app.LoaderManager.initLoader().
Update:
For the equivalent of getLoaderManager, see getSupportLoaderManager.
You can increase the minimum SDK to level 15 and it will work fine.

How to solve java.lang.NoSuchMethodError: android.widget.AbsListView.isItemChecked

I'm compiling an Android project against API Level 11 (3.0) and I have this code:
if (parent instanceof AbsListView) {
checked = ((AbsListView)parent).isItemChecked(position);
}
When I run this in pre-3.0 (lower than API Level 11) devices, I get this error:
java.lang.NoSuchMethodError: android.widget.AbsListView.isItemChecked
In AbsListView documentation, isItemChecked is stated as having API Level 1 compatibility, then why do I get the error?
Apparently this is what happens:
Since API Level 1, Android framework has already isItemChecked on ListView.
However, on the release of API Level 11, Google moved the definition of isItemChecked to AbsListView, which is the superclass of ListView. This change doesn't prevent existing code (meant for compiling against pre-API Level 11) to compile against API Level 11, but the generated .class file actually looks for isItemChecked on AbsListView, which does not exist on pre-API Level 11 devices.
On the API Differences Report, it is stated:
boolean isItemChecked(int) Method was locally defined, but is now inherited from AbsListView.
This is a dangerous pitfall, because the compatibility can't be checked on compile-time at all. You must remember to cast it as ListView and not AbsListView. Maybe we should avoid AbsListView altogther.

Categories

Resources