views:

118

answers:

3

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?

+2  A: 

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

VonC
I am not using any 3rd party jars.The specific functionality of 2.01 i want to use is the multi touch capability i have previusly been using methods of the event that is passed. i supose what i am suposed to do is use a "try" block? i supose that would work. however i still get that verifyerror when i try to construct a new thread that i need.
nathan
@nathan: thet try block won't work. I have completed my answer with more on that `VerifyError` exception
VonC
turns out the problem with the verify errors was that i was compiling wiht 2.01 whil having my target and minum sdk =3, and then testing on avd with 1.5....
nathan
@nathan: thank you for your feedback. I have updated my answer to reflect the root cause of your issue with `VerifyError`
VonC
+2  A: 

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

Christopher
This has got me goign the right direction but the example at that url for using a wrapper class.. well i just dont see how it would compile under eclipes. eclipse will see that the class doesnt exsist and not allow you to build. how do i get past that?I guess what it really comes down to. Is how do i tell eclipse/android to shut up and try anyways, then give me a nice lil error i can handle if it dont work?
nathan
It compiles because you're using reflection; the compiler (and therefore Eclipse) can't detect that the class you're invoking via reflection does not exist at compile time.
Christopher
The first example at that url uses reflections, the second is a wrapper and eclipse will not compile it if the class your wrapping around doesn't exsist or a method your trying to expose doesn't exsist
nathan
You should be compiling against the newer verison of the SDK. If, in that wrapper, you're not executing the newer code (on an older device) then I imagine you shouldn't get a VerifyError.
Christopher
A: 

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.

nathan