Xamarin.Android check API Level - android

I have an Android App that has been developed, compiled and released using the default SDK option
Use Compile using SDK Version
I need to make additions to this application, however I do not know what SDK it targeted at compiled time when it was last tested and released.
The problem being later API levels have different requirements, such as Authorization changes where you need to seek permission from the user. I can see from the code this does not do this, so it must be earlier.
Is there a way to know from source or the previous compiled .apk which SDK was used? I do not have permission to update all of the code to add in all of these authorization changes, just have a few small changes to do.

Maybe you can add your changes inside an if like this:
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.**TheVersionYouNeed**) {
// Your code
}

An .apk is just a zip file, so unzip it and look at the manifest xml file.
Near the top of the file you should find an element that can contain the min, target and max SDK.
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
You will be looking for the targetSdkVersion API level
re: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Related

How can I support API 16 but still have Leanback?

I made my game work on Android TV, it required Leanback library, which wants minSdkVersion to be 17. I must support API 16 too. What can I do?
When building, I get an error this suggestion:
Suggestion: use tools:overrideLibrary="android.support.v17.leanback" to force usage
What exactly does it do? Does it actually make my app still support API 16? What am I losing?
You can find the detailed information here.
Here is what it says:
tools:overrideLibrary marker
A special marker that can only be used with uses-sdk declaration to
override importing a library which minimum SDK version is more recent
than that application's minimum SDK version. Without such a marker,
the manifest merger will fail. The marker will allow users to select
which libraries can be imported ignoring the minimum SDK version.
And you need to do the following: In the main android manifest :
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
tools:overrideLibrary="android.support.v17.leanback"/>
Hope this helps.

Google Play Services : target=android-19 in project.properties

I am utilizing the library BaseGameUtils and google-play-services_lib. In the project.properties file I could see the below mentioned line .
target=android-19.
What is the significance of this? Can I change this to "target=android-21". This is just to be in sync with the App's manifest file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
Yes. You can change this, Depending target only, packages load for you in eclipse.
What is the significance of target=android-19?
target = android-X in project properties file means that Eclipse will not allow use methods or classes from SDK higher than X. It will show compiler errors.
How to change target:
Right click your project.
Then click "Properties".
Then select "Android" from the tree on the left.
You can then select the target version on the right.
NOTE: Before doing this make sure your project.properties and classpath are not in read-only mode otherwise it won't work. Also don't try to edit this file manually.
As a general rule I use the following guidelines
android:minSdkVersion="8"
Set this to the minimum level you want to support. Check which Android version that it actually relates to and make sure that you have compatibility with that version. For example, I think 8 = Android 2.2, which could be a problem if you are using google play services libraries. It is good practice to at least test that you app will work properly on this version using the emulator, because otherwise you will get a lot of errors and bad reviews.
android:targetSdkVersion="21" />
I usually set this to the maximum version that I have actually tested my app on. I thin 21 is Android 4.4, so you should be making sure that your app works correctly on this version of Android. At the least, you should test that it will run in an emulator that is configured with this version of Android.
Hope this helps.

Suppress AndroidManifest.xml minSdkVersion related warning

As recomended here http://developer.android.com/guide/practices/screens_support.html for compatibility reasons my AndroidManifest.xml contains this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
This generates warning in eclipse:
Attribute minSdkVersion (3) is lower
than the project target API level (4)
Are there any means to suppress this warning or get rid of it any other way? It is really annoying.
In short, there is no built-in way to do this that I know of.
Here's a discussion from last August.
And here is a Xavier Durochet's response.
It looks like you can manually remove it according to Mark Murphy's response in the first thread:
Or, you can modify SetupTask.java, eliminate this test (lines 297-308 in
the code indexed by Google Code Search), and build it into a custom
version of the Android Ant extension
There is a feature request that may deal with this, but who knows when it will be implemented.
The answer from 2011 is no longer accurate. It was fixed in ADT 17 according to this bug.
This warning is an usual one. I am using minSdkVersion to support Android 1.5 and I am building for Android 1.6 to support small screens. You can build your application with the latest Android 2.3 library, but still support a lower version.

How i can migrate my app from 1.5 to 1.6 api fast and safe?

i am making a gigantic app for android, and i start doing it some moths ago for android 1.5, but now i know that some of the things i need for my app only can be done if you are programming for 1.6 api.
there is a easy, fast and safe way to migrate my app from 1.5 to 1.6 without having to lose time?
thanks
Since you are going to a newer version, I don't think that any code changes will be needed.
You need to:
1) Update the minSdkVersion in the AndroidManifest.xml. For android 1.6 it should be minSdkVersion = 4. If you don't have that already, it is a good practice to always include it in the manifest. Add this line:
<uses-sdk android:minSdkVersion="4" />
as the last line before the closing tag of the manifest.
2) Change the target (again to 4) in your IDE or ant build scripts. In Eclipse right click your project, select Properties, Android and change the Project Build Target. Your project will recompile, when you click the Apply button.
Then, do a re-compile. I don't expect any errors to occur, but if they do, they will only be a few and you will be able to correct them quickly.
I use the following in my manifest file:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
At the same time I have configured Eclipse to use the Android 2.2 API. This way I ...
support small screens
can use the latest features (as long as I do it with care)
android 1.5 users can still use my app (as long as I make sure it degrades gracefully)
See http://developer.android.com/guide/appendix/market-filters.html

Not able to use new resource identifiers in Android with targetSdkVersion defined in manifest

I'm developing an Android application that I'd like to be compatible with 1.5 (SDK version 4). I'm testing the application on 2.2 (SDK version 8). To do this, I'm including in the manifest file the line
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
I thought this would allow me to use the newest manifest elements and APIs, but I'm getting a compile error whenever I try to use them. For example, I try to define the element installLocation to allow the app to be installed on the SD card, but Eclipse gives me the error
No resource identifier found for attribute 'installLocation' in package 'android'
Is there something else I have to do to get this to work? If I can't get this to work, what benefit is defining targetSdkVersion?
Make sure that you are using building against the android 2.2 jars. Right click on your Eclipse project, choose, properties, go down to Android and make sure the correct sdk is selected.
Change the build target by editing the project properties in Eclipse, and choose a target with at least API Level 8: ("I'm testing the application on 2.2 (SDK version 8)").

Categories

Resources