Basic tutorial for Android Program Development (3)

Source: Internet
Author: User

Debug your project

 

This is usedEclipseInAndroidPlug-inEclipseThe debugger in also has excellent compatibility. To demonstrate this, let's createBugInCode, Change yourHelloandroidSource codeAs follows:

 

 
Public class helloandroid extends activity {
/** Called when the activity is first created .*/
 
@ Override
 
Public void oncreate (bundle icicle ){
 
Super. oncreate (icicle );
 
Object o = NULL;
 
O. tostring ();
Setcontentview (R. layout. Main );
 
}
 
}

 

 

This simple change will causeNullpointerexceptionException. If you run it againProgram, You will see the following screen:

 

To find out where an error occurs, you need to set a breakpoint in your source code"Object o = NULL ;"After line(You can double-clickEclipseThe Left area of the number of rows),Then selectRun-> debugSelect the last running load. Your program will restart the simulator, but it will be suspended at this time. When it goes to the breakpoint you just setEclipseIn the debug mode view of, it will stop in your code. Just as you can do this in any other program..

 

  

 

 

Use other ide tools to create a project

 

If you do not useEclipse (For example, if you use anotherIDEDevelopment tools, or simply use text editing and command line tools)So this plug-in won't help you, don't worry, you won't be using itEclipseWithout any development capability.

 

ActuallyAndroidOfEclipseThe plug-in also integrates a setAndroid SDKDevelopment tools are packaged.(These tools are like simulators,Aapt, ADB, ddms,For more information, seeGoogleRelated Documentation)Therefore, it can also be packaged by other tools, suchAnt.

 

InAndroid SDKContainsPythonScript, called"Activitycreator. py"It is used to create all the source code and directory compilation environments for your project.(Personal Understanding),That isAntCompiledBuild. xml.In this way, your project can be created or integrated toIDE.

 

For example, to createHelloandroidProject, just as we usedEclipseYou can use the following command:

 

 
Activitycreator. py -- out helloandroid com. Google. Android. Hello. helloandroid

 

 

To compile your project, you need to useAntCommand, when the command line prompts a success, you will seeHelloandroid.apkFile in"Bin"Directory. This. APKFile isAndroid, It needs to use"ADB"Install the tool in the simulator.

 

So far, I have shown youAndroidA simple development example of the platform program. I have a limited level, and the translation time is too short. There must be many errors and omissions. Please submit more comments for modification. The main content of this series of tutorials is translated fromGoogleOfAndroidDevelopment document. View All content through the link below.

Http://code.google.com/android/intro/hello-android.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.