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" />
Related
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
}
I have imported a project with these settings :
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
and I had already downloaded the packages 18 , 15 and 8.
There is an error saying : "unable to resolve target 16" , would you know why? Is there somewhere else an option that would say "API 16 needed" ? And isn't it enough to have already the 3 packages ?
Thanks
There is an error saying : "unable to resolve target 16" , would you know why?
The build target of the project (e.g., Project > Properties > Android) was set to API Level 16. Eclipse should have automatically changed it to 18, given your described setup (first available higher SDK).
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.
When I try to install apk on devices whose sdk level is less than what is mentioned in manifest, I get Parse error message. My question is, is there a way through which we can show a custom message to the user? For example: this app requires min android version to be ICS or something like that.
<uses-sdk
android:minSdkVersion="8" />
Just put it in your androidmanifest.xml file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
then inside onCreate you can check the sdk version as bellow:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
and show a dialog telling the user that this app requires min android version to be ICS
then finish the application !
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