How to run the main method of the Android Activity class?

I would like to learn the Android Activity private method by doing it in the main action public static void main (String [] args) that I created.

I am using Eclipse ADT , and my naive approach to starting Activity as a Java application resulted in:

Fatal error detected in Java Runtime Environment:
Internal error (classFileParser.cpp: 3174), pid = 2936, tid = 2980
Error: ShouldNotReachHere ()

So, I looked at Run Configuration and found out that Android 3.1 is the only entry in the Classpath Downloads section . I was able to configure the project build path so that the JRE is in Bootstrap Notes . Then I deleted the Android 3.1 entry and added android.jar to the User Entries .

Run Configuration results in a RuntimeException:

Exception in thread "main" java.lang.RuntimeException: Stub!
  in android.content.Context. (Context.java:4)

An alternative execution of some tests would be to run the JUnit test . But in the case of the private method, this is cumbersome.

Is there a way to successfully run the main method of the Android Activity class?

+5
source share
3 answers

There is another variant of the problem if the method privatethat must be checked when the main method is executed can be extracted to another class . This, of course, means that the method suddenly became no less protected.

, android.app.Activity a . Eclipse.

  • Java. ,
  • Android Bootstrap Classpath
  • JRE 6
  • JRE Bootstrap
  • android.jar, Android SDK
+4

Android, - , .

public void onCreate(Bundle savedBunldeInstance)

, , . android. Android. compiled 2 times, - java compiler then by dalvik compiler.

DVM (Dalvik Virtual Machine) Android (EMULATOR OR PHYSICAL), ... onCreate - .

. http://developer.android.com/

 Android applications don't have a single entry point.
 (there no main() function, for example).

:

http://developer.android.com/guide/topics/fundamentals.html
+2

The main method is not an entry point in Android, as in Java. Do you want to override

public void onCreate(Bundle savedBunldeInstance) method.
0
source

All Articles