I am getting a NoSuchMethodError on Camera.Parameters.isAutoExposureLockSupported()
How can this be avoided?
I am using:
android:minSdkVersion="8"
android:targetSdkVersion="17"
running application on HTC Wildfire S with Android 2.3.5
isAutoExposureLockSupported() was added in API level 14.
You will need minSDKVersion to be 14 if you want to use this. Your HTC Wildfire S with Android 2.3.5 has no idea about this method.
To fix, you can raise the minimum required SDK version in your manifest, or don't use it in lower versions by doing a version check at runtime.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// call isAutoExposureLockSupported() and do whatever you need
}
Related
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
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.
I am confused about the target build and sdk usage
Lets say I have this code
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
//do xyz
}
Let say that I built against API 19 (kitkat) and my target api in manifest is 19 and my minimum supported api is 9
Now if a device with API 9 runs the above code, will it crash? I expect the answer is yes becasuse it will not understand what Build.VERSION_CODES.KITKAT means. However, what's the point of the check above then in first place?
Please help clarify this
Thank you
It won't crash. Simply the code within the if won't be executed. Build.VERSION_CODES.KITKAT is a constant field, and as you can read here, the constant fields are replaced with the numbers themselves by the compiler.
lesser versions of android will use the support library, if the check for kit-kat fails, it will revert to the closest possibkle form that version supports.... via the support library...
you cannot run you app on anything less than the minimum version, but it will find a way to run with less than the target version as long as its aboe the minimum
No, it won't crash, because its Build.VERSION.SDK_INT value is 9. It simply will not enter inside your if clause. Only devices that have API version 19 or above will run your code inside the if. Build.VERSION_CODES.KITKAT is equal to 19.
The code you posted won't crash because the class Build is created and compiled for every build of your app (as the R file) depending of the target API you set in the manifest
As you setup your target API to 19, the Build class will contain the field Build.VERSION_CODES.KITKAT because it exists starting from API level 19.
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" />
While running my application i am getting the below given warning and application went force close.
[2011-10-17 12:09:09 - LunarLander] WARNING: Application does not specify an API level requirement!
[2011-10-17 12:09:09 - LunarLander] Device API version is 9 (Android 2.3.1)
How to resolve this. I created another emulator with API level 10, then also i am getting the same error.
I am sure you forget to define the API level inside the AndroidManifest.xml file, define it as:
<uses-sdk android:minSdkVersion="5"
android:maxSdkVersion="10"
android:targetSdkVersion="8"/>
You should define the API level of your application in manifest file. I think you forgot to that. Launch the application according to that.
Just looking at that error you need to specify an API level for your application:
http://developer.android.com/guide/appendix/api-levels.html