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

こ雲淡風輕ζ 提交于 2019-12-06 08:40:59

问题


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 thats 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?


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/2368898/how-do-i-use-the-features-of-2-01-yet-still-support-1-5-with-one-apk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!