开发者

How do I use the features of 2.01, yet still support 1.5 with one apk?

开发者 https://www.devze.com 2022-12-21 15:07 出处:网络
I would like my activity to use some features of 2.01, but i need it to be able to run on 1.5 devices. I understand that the 1.5 devices will not be able to run the 2.01 features and t开发者_如何学Pyt

I would like my activity to use some features of 2.01, but i need it to be able to run on 1.5 devices. I understand that the 1.5 devices will not be able to run the 2.01 features and t开发者_如何学Pythonhats fine. But i still want them to be able to use the rest of the activity.

I am using Eclipse as my IDE, how do i setup my project correctly? what am i going to have to watch out for? and what the heck does verifyerror mean?


See http://developer.android.com/resources/articles/backward-compatibility.html


For the VerifyError part, the question Android java.lang.VerifyError? mentions the necessity to run any 3rd party JAR files through the "dx" tool that ships with the Android SDK.

The compatibility section of Android mentions:

If your application uses APIs introduced in the latest platform version but does not declare a android:minSdkVersion attribute, then it will run properly on devices running the latest version of the platform, but not on devices running earlier versions of the platform.

So that attribute needs to be set (to 1.5 in your case), while you are compiling your project with a 2.0 SDK.

In the case of the OP nathan:

I was compiling with 2.01 while having my target and minimum sdk =3, and then testing on avd with 1.5.


This thread adds:

Pretty much all VerifyErrors are build errors

According to this one:

Android 2.x will give you a more specific exception (NoSuchMethod, ClassNotFound) at the point of the failure rather than an ambiguous "VerifyError" for the entire class. Unfortunately it's likely failing on the older versions of the OS.

Sometimes, this error is about a missing class, or missing jars, or because of some process space need to be separated with android:process=":otherProcess" tag.


So what that means is:

Trying to catch such a VerifyError exception is likely to fail.
See can’t catch java.lang.VerifyError

As a general rule, it's a good idea to tick the "Filter by API level" checkbox when browsing the API documentation


To sum things up.if you are a android developer using the eclipse ide, and you want your activity to be compatible with 1.5 devices. And you want to add some class Or method from 2.01 etc. You can use the directions @ http://developer.android.com/resources/articles/backward-compatibility.html What the directions there don't state is that if you use the wrapper method ,you should set eclipse to compile with the version that the wrapper needs. Also be sure to set your minsdkversion correctly to 3 in the android manifest.

0

精彩评论

暂无评论...
验证码 换一张
取 消