Android compatibility settings in AndroidManifest.xml

I have a release application that works on all Android screen sizes (except for the smaller size) and density higher than SDK version 2.0.

It will also work on large screens. I have currently added this:

<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="false" android:anyDensity="true" /> 

But I also need to add android:xlargeScreens="true" so that it appears on the Android market on extra large screen devices, since by default it is false.

But to add android:xlargeScreens I need to change the settings of the eclipse target set to 2.3, since this attribute was added from API level 9.

So what should I do with my target compilation settings for this scenario? Should it be 2.3 at compilation? If so, will the application not give any problems while working on devices with version 2.0?

+4
source share
7 answers

When reading this blog post, I think I have an answer to my old question. The following is a snippet (which for the other manifest attribute "requires SmallestWidthDp" from 3.2):

"The trick is that you must compile your application against Android 3.2 or higher in order to use the requireSmallestWidthDp attribute. Older versions do not understand this attribute and raise a compile-time error. The safest thing to do is to develop an application against a platform that matches API level set for minSdkVersion. When you are making the final preparations for creating a release candidate, change the build target to Android 3.2 and add the requireSmallestWidthDp attribute. Android versions older than 3.2 just ignore this ut XML, so theres no risk of failure at run time. "

0
source

Yes, you need to change the use of sdk to 2.3, but make sure you are not using a new apis that is not in version 2.0 or regardless of your minimum supported version of sdk. Or, if you want to use them, you must use reflection.

But more about using sdk versions here and more about uses-sdk here .

I am doing the same in my application and testing your application in both versions before you release it.

Best, Achie.

+2
source

I am moving this from comments to make it more understandable to others considering this issue in the future.

With the support of both old and new versions of Android, you can be confused how applications can work, despite the fact that many changes change as part of each new version, I will try to clarify this here.

An application written for 1.5 sdk can only call functions that exist for this API level, therefore, for example, multi touch api does not exist in 1.5 and never will. Now you say โ€œOk, but I donโ€™t need to call any new APIs, I just want my application to work in version 2.3 and support a2sd supportโ€ And I say โ€œOk, just change your targetApi in the manifest, set minSDK and compile against 2.3, and you're good to go. "

Now why does it work? What if the onMeasure () method for ListView was changed to 2.2 and now calls betterCalculateFunction () inside onMeasure ()? Why is my application still running?

This is the advantage of late binding in Java. You see, Java never compiles until it reaches the device and starts up, what you do in Eclipse will convert it to byte code, which contains a bunch of byte code instructions that are later interpreted by the device. The bytecode will NEVER contain a link to betterCalculateFunction (), though (unless you call it directly). The call to onMeasure () is indirect). This can happen because when your code runs on the device, it is connected to the Android framework on the device, and your code calls onMeasure () directly, because it is an open API. The execution path will then go into the framework and call everything that it needs, and then after it is completed, it will return to your code.

So at 1.5 you can see

doStuff (your code) -> onMeasure (public API) -> done

and 2.2

doStuff (your code) -> onMeasure (open API) -> betterCalculateFunction (private function) -> done

Now, if you need to call functions that may or may not exist depending on the API level, I suggest you look at my own answer fooobar.com/questions/1337903 / ...

Hope this clarifies some things.

+2
source

I have not tried 2,3, but this is what I do with 2.2.

I am compiling for 2.2 and checking 1.6 to make sure everything is working as I expect. I have not encountered any problems.

To do a double check, set 2.3 for your purpose, and then configure the emulator for a lower rev version to make sure that it all works.

0
source

The default value for android: xlargeScreens is true, so you do not need to change anything - it is enabled by default if your minSdkVersion or targetSdkVersion is greater than 4. http://developer.android.com/guide/topics/manifest/supports-screens-element .html

0
source

Here is the official Android developer blog explaining how this works:
http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html

In short: you can use the latest XML while keeping legacy OS versions in reverse.

0
source

For different screens, you need to create several apk and then reduce the size of your application. In each application manifest, you must identify the following link. http://developer.android.com/guide/practices/screens-distribution.html

-1
source

Source: https://habr.com/ru/post/1337902/


All Articles