Prasanna Perera wrote:
> I wanted to test an Android code segment.  I created an Eclipse
> ScrapBook for this testing.  The project that includes the ScrapBook
> has the android.jar from the Android SDK in its build path.  When I
> execute the Android code segment I get a:
> 
> “java.lang.RuntimeException: Stub!” error.
> 
> By doing some research on the internet I found that the android.jar
> has the Android API and not the actual implementation of the API.  The
> emulator and phones have the actual implementation of the API.  Is
> this correct?  Is there a method for me to get a jar file that has the
> actual implementation of the Android API to do something like what I
> was trying to do?

If your goal is to test Android code outside of Android, that will be
impossible. Android is an operating system, not merely a JAR.

Actually, "impossible" is probably too strong. Given several
staff-years, you could probably create a JAR that mocks what it has to
and uses real stuff for the rest.

I would imagine it will be more expedient to isolate the "Android" from
the "code segment" and test the code as pure Java. For example, you
might mock whatever Android bits you are relying upon, with some sort of
pluggable interface to allow you to swap between the mock (for
outside-of-Android testing) and the real implementation.

See:

http://stackoverflow.com/questions/2755470/can-i-use-android-os-libraries-in-a-standalone-project

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to