I am learning how to develop Android apps, using Eclipse. New to all of this, and apparently there is a bug that messes up the "Graphical Layout" pane of Android XML files when you add a box of plain-text. I've read solutions saying to change the input type, but I'm not deep enough into Android for it to really make a difference between using API 16 or 15. I am currently using 16, I downloaded 15 today, and am trying to find a way to make Eclipse use the older API. How do I switch Eclipse over to use API 15 instead of 16? (I'd prefer not to uninstall API 16, but if I must, oh well).
Open the manifest file and change the line
<uses-sdk android:minSdkVersion="number-of-version-you-want" />
Related
Whenever I create a blank activity layout file assigned to be rendered at API level 22, following error message is generated
The solution to this is to change the API level by changing it to API 21 or less.
What is the reason behind this?.
This was very common for me when a new API SDK version was released and yes like you mention we have to change the Android version to use when rendering layout in the IDE.
But this time i have installed all the elements described in the Android SDK Manager for this API 22 and I have no problems with the rendering.
You can just change "AppTheme" to another theme and keep the API level as you desire.
Many users are reporting this problem and it happens only in the Layout files that uses support libraries and not the normal ones.
I have been working with Android Developer Tool since long time without issue.Recently I updated my ADT and now I am unable to create a simple activity by (New->Other->Android Activity).It is providing only option to create Action bar Activity.
So How to create simple activity with layout
My ADT version is 22.6
Why is this happening
The template that you are trying to add uses features (like the actionbar) that requires an API level higher than 14, in the first step of the wizard, you selected 9. And since 9 < 14 you get this error.
What can I do
Chose an higher minimum API level (at least 14 for this template). Go back to the first step and change the minimum api level.
Chose a different template that is more compatible, by going back one step and select the most basic template.
Which should I pick
If you think it doesn't matter to use an api level higher than 14 (so your device won't work on pre-ice cream sandwich devices), you should definitely take the first option. If you don't mind using a more basic-UI template to start with, and you really require your app to work on pre-ice cream sandwich devices. You should pick the second option.
What if I want both
You could use a support library, this way you can enjoy API level 14+ features on pre API 14 devices. Some consider it more difficult to setup & use though. https://developer.android.com/tools/support-library/setup.html there are also samples available.
EDIT: In step below, you can select the kind of template:, notice the checkmark "create Activity", just uncheck it.
When you create project then you must set options: min SDK, target SDK and Compile With.
You can set min SDK to 10, target SDK to 10, but "Compile with" set to API 14.
A workaround for this irritation would be to set the API level to 14, create the new activity, and then change the API level back to what you want it to be. This seems to be an issue with this version of ADT and the new Activity creation wizard.
This used to work before, but I recently updated ADT and now I'm seeing issues on projects I haven't changed.
I've been doing this to create new activities and haven't seen any problems yet.
Hello I have developed my first application for Android using the Ice Cream Sandwich SDK and I was wondering if there was a way to make this compatible for devices also running Gingerbread without having to re-do the entire program. I have tried to find the answer to this from other sources but haven't found anything yet. Thank you for your time.
Congratulations for the development of your first application ;)
It's difficult to answer to your questions without knowing what your application is using. If your application use new features of the Android ICS API, you have to implements some compatibility code (see Support package). If not, you just need to add this in your AndroidManifest.xml :
<uses-sdk
android:targetSdkVersion="14"
android:minSdkVersion="7"
/>
Note that 7 is for Android 2.1
The best way to know if you use specific API of Android 4 (ICS) is to try to launch your project on an emulator under a lower version. If this give you error(s), it's because you have compatibility problems.
Just set your build target in Eclipse to Android 2.3. If you get any compilation errors in Eclipse, than this means that you are using APIs that are not available in 2.3 and your application will crash when it is going to reach at those lines when running on 2.3> .
Just make sure youre using APIs that are there on older versions of Android. Try to read the wahts new for ICS and avoid those :) which pretty much beats the purpose of using a newer SDK that changes alot and breaks lots of things. Beware of the new layouts....
I have been developing an android app. I had chosen 2.2 as the version. I have not used any advanced features that are specific to 2.2 or above. I want my app to work with 1.6 and above. What should I do?
Thanks.
You should read this http://developer.android.com/guide/publishing/versioning.html
Complement preview answers.
android make upward compatible your code automatically as much as possible (not always).
But lowering the api level of an app. Can be a task from simple to nightmare to execute, all depends if your code use a lot of specific 2.2 ...
That's means changing API level or android.jar in your project may be far to be enough.
good luck
Open the AndroidManifest.xml file and change to :
<uses-sdk android:minSdkVersion="4"/>
At first you should set android:minSdkVersion="4" in the Android Manifest file.
Next step is to do some testing on an android vm with version 1.6.
Even better would be to test on a real device, but the compiler should give you enough hints what to change in your program.
I have an app to release which works on all android screen-sizes (except smaller) and densities above SDK version 2.0.
It will also run on extra large screens.
Currently I have 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" , to allow it visible in android market on extra large screen devices, since by default it is false.
But to add android:xlargeScreens I need to change my eclipse targetsettings to 2.3 as 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 while compiling ? If yes, then will the app not give any problems while running on devices with 2.0 version ?
Yes you need to change the uses sdk to 2.3 but make sure that you are not using any newer apis which are not in 2.0 or whatever your minimum supported sdk version is. Or in case you want to use them you have to use reflection.
But more about how to use the sdk versions is here and more about uses-sdk is here.
I do the same in my application and make sure you test your application in both[all] the versions before you release.
Best,
Achie.
I'm moving this from the comments to make it more clear for others looking at this question in the future.
When supporting both old and new versions of Android it can be confusing how applications manage to run despite many things change with in the frameworks during each new release, I'm going to try and clarify this here.
An application written for the 1.5 sdk can only call functions that exist for that API level, so for instance the multi touch api's didn't exist in 1.5 and never will. Now you say "Ok but I don't need to call any newer APIs, I just want my app to work in 2.3 and have a2sd support" And I say "Ok, just change your targetApi in the manifest, set the minSDK and compile against 2.3 and you're good to go."
Now why does that work? What if the onMeasure() method for ListView was changed in 2.2 and now calls betterCalculateFunction() within onMeasure()? Why does my app still work?
This is the advantage of late binding in Java. You see, Java is never compiled until it reaches a device and is running, what you are doing in Eclipse is converting it to byte code which contains a bunch of byte code instructions that are later interpreted by the device. The byte code will NEVER contain a reference to betterCalculateFunction() though (unless you directly call it. Calling onMeasure() is indirect). This can happen because when your code is running on the device it gets linked against the Android framework on the device and your code calls onMeasure() directly because it is a public outward facing API. The path of execution will then enter the framework and call whatever it needs to, then once its done return to your code.
So on 1.5 you might see
doStuff (your code) -> onMeasure
(public API) -> done
and 2.2
doStuff (your code) -> onMeasure
(public API) ->
betterCalculateFunction (private
function) ->done
Now if you need to call functions that may or may not exist depending on API level then I suggest you look at a related answer of mine here stackoverflow: gracefully downgrade your app
Hope that clears some things up.
I haven't tried 2.3, but that's what I do with 2.2.
I compile for 2.2 and test on 1.6 to make sure everything works how I'm expecting. I haven't run in to any issues with it.
To double check, set your target for 2.3 and then setup an emulator for a lower rev version to make sure it all works.
The default value for android:xlargeScreens is true, so you don't have to change anything - it's on by default, as long as your minSdkVersion or targetSdkVersion is higher than 4.
http://developer.android.com/guide/topics/manifest/supports-screens-element.html
Here is an official Android developer blog explanation of how this works:
http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html
In summary: you can use the newest XML whilst still supporting the older OS versions in a back compatible way.
While reading this blog post I guess I have an answer on my old question. An extract below (which is for another manifest attribute "requiresSmallestWidthDp" introduced from 3.2):
"The catch is that you must compile your application against Android 3.2 or higher in order to use the requiresSmallestWidthDp attribute. Older versions don’t understand this attribute and will raise a compile-time error. The safest thing to do is develop your app against the platform that matches the API level you’ve set for minSdkVersion. When you’re making final preparations to build your release candidate, change the build target to Android 3.2 and add the requiresSmallestWidthDp attribute. Android versions older than 3.2 simply ignore that XML attribute, so there’s no risk of a runtime failure."
For different screens you have to create multiple apk then it reduces size of your application.In each application's manifest you have to define according to following link.
http://developer.android.com/guide/practices/screens-distribution.html