Basic4android development tutorial (1) create a simulator and the first hello worlrd Program

Source: Internet
Author: User

If you have not installed the basic4android and Java sdks, please refer to the installation and configuration methods in the link below:
Http://www.basic4ppc.com/forum/basic...droid-sdk.html

In this tutorial, we will create a new AVD (Android Virtual Device) and generate a simulator instance. then we will create a simple program, which will display a simple information box and write a message to the log.
You can also connect to a real device through ide:
Use ADB to connect to your device
Connect your device with a B4A-Bridge
The common problem solving is listed after this tutorial. If the problem you encounter is not listed or cannot be resolved, please contact the support@basic4ppc.comContact

Create a new AVD

-Run basic4android.
-Choose tools> run avd manager.
Wait a few seconds.
-SDK managers of different versions and configurationsMay be different. You need to select Tools-manage avds.

-AVD Manager:

-Select New and enter a similar field (hvga is recommended ):

-Click Create AVD.
-You can create multiple avds. Each one can have different resolutions or correspond to different api versions (you need to install additional platforms first ).
-Click start to start the simulator.

-You will see several windows pop-up and disappear. This is normal.
-Start the simulator:

Wait...It takes several minutes to wait until the simulator is ready for the first time.

When the following screen is displayed, the simulator is ready:

You may also see the screen below, which is the screen lock interface:

Drag the unlock icon to the Right to unlock the device.

There is no need to restart the simulator every time the program is distributed. The simulator remains running.

If you are not familiar with Android, You can first use the simulator. Press the small box button in the middle to enter the application page.

Troubleshooting: If you encounter an error message similar to the following:
Invalid command-line parameter: files \ Android-SDK \ tools/emulator-arm.exe.
Hint: Use '@ foo' to launch a virtual device named 'foo '.

Then you need to reinstall the android SDK to a directory without spaces, such as c: \ android.

Write the first basic4android Program

-Because this is a new program, you must first select File-Save to set the storage location.
We strongly recommend that you save each project to your own directory.
-Create a directory: "Hello World", open the directory, and save the program as "Hello World ".

-Enter the following code in sub activity_create:

Code:
Sub Activity_Create(FirstTime As Boolean)
Log("Hello world!")
Msgbox("Hello world! ","First program")
End Sub

-Press F5 to compile and release your program to the simulator.
The package dialog box appears (blank ):

Each Android Application is identified by a unique package name.
This is a composite string separated by commas.
This string should contain at least two parts. You cannot install two different applications using the same package name to a device.
You can use the Tools menu to change the package name at any time.

-Enter the package name.
-Next, you will be asked to enter the application tag. This is the name of the application you see.

Your program is now compiled and installed on the simulator:

Simulators are much slower than real devices.
Because the installation is fast, it is easier to directly work on the real device in many cases.

You can re-release your program at any time without shutting down the program running on the simulator.

Use logcat to track logs

The Android device retains an internal buffer to store log information. You can use this information to conveniently debug the program.

You can switch to the logcat panel and press connect to view logs:

When we run this program twice, we can see two "Hello world! "Information.
If you deselect the filter check box, all information is displayed (not just your program information ).

Hello World

FAQs
-"Emulator: Error: No search paths found in this AVD's configuration
Weird, the AVD's config. ini file is malformed. Try re-creating it ."
This problem occurs when your Windows user name contains non-ASCII characters, because the android SDK fails to find the corresponding directory.
The solution is to create a directory named c: \ Android, add an environment variable android_sdk_home, and set the value to c: \ android.

-"Invalid command-line parameter: files \ Android-SDK \ tools/emulator-arm.exe.
Hint: Use '@ foo' to launch a virtual device named 'foo '."

This error occurs because the android SDK is installed in a directory with spaces. This problem is solved by copying the SDK to c: \ Android and updating the configuration path.
-"Javac: Target Release 1.5 conflicts with default source release 1.7 "-

Currently, basic4android requires Java 6 to run. Java 7 is not supported. However, these two versions can be installed on the same computer at the same time.

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.