Android pdfrenderer not working properly with 19 or 21 minsdk - android

Making a program for Android L' using pdfrenderer the issue is
when 'm running the emulator with minsdk = 21
ERROR - "emulator-5554 disconnected! Cancelling 'com.example.andro_pdf_two.MainActivity activity launch'!"
when 'm trying to run the emulator at minsdk = 19
ERROR at logcat- java.lang.NoClassDefFoundError: android.graphics.pdf.PdfRenderer
and Call requires API level 21 (current min is 19): android.graphics.pdf.PdfRenderer#openPage
I have done everything as suggested - resetting adb, resetting preferences...but nothing seems to be working can anyone help???

Call requires API level 21 (current min is 19): android.graphics.pdf.PdfRenderer#openPage
clearly states that you need a min sdk version of 21 and your app has a current api level of 19
set this in your manifest and try
<uses-sdk android:minSdkVersion="21" />

PDFRenderer assumes minimum API level - 21.
You can use android-pdfview for API level less than 21.

Related

android:navigationBarDividerColor requires API level 28

Previously, I implemented light and dark navigation bar, however now tags as android:navigationBarDividerColor and android:windowLightNavigationBar require API level 28 when they previously required API level 27.
It seems API level 28 does not even exist as next API level is called P.
Is there any solution to this problem? Thanks in advance.
UPDATE: it seems to work now on API 27 with latest support libraries
When the "next upcoming API" is still under development, its "name" is a letter (P in your case).
Once the final version of the API is available, the "name" is changed form a letter to a number (P to 28).
Final version of Android API 28 (former Android P) is available since early June 2018. Just use the SDK manager and you'll be able to download it ;-)
Note:
Sources for "Android SDK Platform xx" (28 in your case)" is not available right away. (not available ATTOW)It can takes a few weeks before they are available for download from the SDK manager.
Today I've updated compileSdkVersion, targetSdkVersion and buildToolsVersionfrom 27 to 28. Now I'm facing the same issue as #Teďourek described.
While it was working for me on 27, since the upgrade I now get lint errors:
Error: android:navigationBarDividerColor requires API level 28 (current min is 19)
Error: windowLightNavigationBar requires API level 28 (current min is 19)
This is strange because according to the docs for both attributes it says:
"added in API Level 27"
My temporary fix is to move the two style attributes to v28/styles.xml instead of v27/styles.xml
Since I would like to use lightNavBar + color also on Android 8.1.0 as previously, I would be happy if anyone knows a fix!
With compileSdkVersion and targetSdkVersion set to 29 it seems to be correct.
The XML properties tell me it was added in API level 27.
Only the Java Window properties are added in API level 28.

How to use android:usesCleartextTraffic below Marshmallow (API-23)

I am trying to secure WebView from cleartext traffic. As mentioned in the documentation. I have to set android:usesCleartextTraffic as false to achieve this. But this works on API level 23 and above. My minimum sdk is 22. How can I make sure app doesn't crash or create any problem on device running below API level 23 ? Or how can I programmatically set that attribute value in the application tag in Manifest.xml ?
As suggested in an article # Android Developers Blogspot:
You don’t have to set minSdkVersion or targetSdkVersion of your app to 23 (Android Marshmallow) to use android:usesCleartextTraffic. On older platforms, this attribute is simply ignored and thus has no effect.
Hope this solves your query.
When you use usesCleartextTraffic in manifest, you get the following warning :
Attribute usesCleartextTraffic is only used in API level 23 and higher
(current min is 19).
The default value of usesCleartextTraffic is as the following :
for apps that target API level 27 or lower is "true".
for apps that target API level 28 or higher default to "false".
This attribute was added in API level 23.
This flag is ignored on Android 7.0 (API level 24) and above if an Android Network Security Config is present.
https://developer.android.com/guide/topics/manifest/application-element
https://android-developers.googleblog.com/2016/04/protecting-against-unintentional.html

Does NewApi check in Android Lint is based on classes SDK level only?

I'm quite new with Android development, and I wanted to learn a bit about Lint tool and NewApi check. After doing some tests I'm a bit confused though.
After creating new Android application project in IntelliJ IDEA, I added some code to the onCreate method, so it now looks like this:
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Display d = getWindowManager().getDefaultDisplay();
Point size = new Point();
d.getSize(size); // API level 13
isDestroyed(); // API level 17
NativeActivity nativeActivity = new NativeActivity(); // API level 11
nativeActivity.getContentResolver(); // API level 11
Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); // API level 9
boolean canDisableShutterSound = cameraInfo.canDisableShutterSound; // API level 17
}
In the manifest file I have
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" />
After compiling the project and running lint from command line:
lint --check NewApi --classpath c:\_dev\TestNewApi\out c:\_dev\TestNewApi
I got the following output:
Scanning TestNewApi: .......
out\production\TestNewApi\com\example\TestNewApi\MyActivity.class: Error: Call requires API level 9 (current min is 7): android.app.NativeActivity#getContentResolver [NewApi]
out\production\TestNewApi\com\example\TestNewApi\MyActivity.class: Error: Call requires API level 9 (current min is 7): new android.app.NativeActivity [NewApi]
out\production\TestNewApi\com\example\TestNewApi\MyActivity.class: Error: Call requires API level 9 (current min is 7): new android.hardware.Camera.CameraInfo [NewApi]
out\production\TestNewApi\com\example\TestNewApi\MyActivity.class: Error: Field requires API level 9 (current min is 7): android.hardware.Camera.CameraInfo#canDisableShutterSound [NewApi]
4 errors, 0 warnings
So no complaints about getSize and isDestroyed methods. And after changing minSdkVersion to 9, the check result is:
Scanning TestNewApi: .......
No issues found.
It looks for me, like only the classes are checked in both cases, and if the class was introduced at or after minSdkVersion, then everything is ok. Is this the expected behavior? Or maybe I'm missing something?
Is this the expected behavior?
IMHO, no. I see the same behavior in Eclipse, and IMHO this is a bug. Normally, Lint will complain about methods that are newer than your android:minSdkVersion or #TargetApi(). I'm not quite certain why it is not doing that here.
I have filed an issue related to this.

Android SDK Check Not Working

I am trying to change the transition from default to sliding in. I would like to keep my minSdkVersion to be 3 however overridePendingTransition wasn't added until API level 5 (Android 2.0).
I tried creating an integer to represent the SDK version and then only override the transition when in Android 1.6 or less via a simple if statement.
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if(sdkVersion>=5)
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.fade_out);
Eclipse gives me a LINT warning stating "Call requires API level 5 (current min is 3): android.app.Activity#overridePendingTransition"
If I suppress this error and run it anyway it crashes on Android 1.6 or lower.
What is wrong with my code and how can I fix it? Any suggestions would be very appreciated!
In your android manifest file you have this ...
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="latest version" />
Change the min sdk version to 5 like show below
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="latest version" />

What does Advanceable Added in API level 16 mean?

What does Advanceable Added in API level 16 mean? And how to use those two methods in Advanceable Api?I saw this interface in Launcher source code. I am not clear about the specification in android docs.Thanks.
It means that only devices with api level 16 or above knows/can use that method/class. And will fail to run if you put the code under a device with api level 15 or lower.

Categories

Resources