Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Getting started & Tutorials
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4android Getting started & Tutorials Android development starts here. Please do not post questions in this sub-forum.

Hello world - Installing Android Emulator

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2010, 08:29 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Hello world - Installing Android Emulator

Please follow the installation (and configuration) instructions if you have not done it yet:
http://www.basic4ppc.com/forum/basic...droid-sdk.html

In this tutorial we will create a new AVD (Android Virtual Device) which is an emulator instance. Then we will create a simple program that displays a simple message box and also writes a message to the log.
You can also connect a real device to the IDE:
Connecting your device with ADB
Connecting your device with B4A-Bridge
Common issues are listed at the end of this post. If you encounter an error that is not listed or that you are unable to solve, please contact support@basic4ppc.com

Create new AVD

- Run Basic4android.
- Choose Tools Menu - Run AVD Manager.
Wait a few seconds.
- The SDK Manager may appear depending on the version and configuration. You should choose Tools - Manage AVDs.



- The AVD Manager should appear:



- Choose New and fill the fields similar to the following image (it is recommended to choose HVGA) :



- Press on Create AVD.
- Note that you can create more than one AVD. Each can have a different resolution or can target a different API version (you will need to install additional platforms first).
- Now press Start in order to start the emulator


- You will see several windows popping up and disappearing. This is fine.
- The emulator should boot up:



Wait... on the first time it can take several minutes till the emulator is ready.

The emulator is ready when it gets to this screen:


You may see this screen, which is the lock screen, instead:


Drag the lock icon to the right to unlock the device.

Note that there is no need to restart the emulator each time you deploy a program. The emulator can be kept running all the time.

If you are not familiar with Android you can play with the emulator. Press on the button with the small squares to get to the application page.

Troubleshooting: If you get an error message similar to:
invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
Hint: use '@foo' to launch a virtual device named 'foo'.

Then you should reinstall Android SDK in a path without spaces, such as c:\android.


Writing your first Basic4android program

- As this is a new program we should first set its location by choosing File - Save.
It is highly recommended to save each project in its own folder.
- Create a new folder: "Hello world", open the folder and save the program as "Hello world".

- Write the following code under 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 deploy your program to the emulator.
The package dialog should appear (empty):



Each Android application is identified by a unique package string.
This is a string built of several parts separated with periods.
The string should include at least two parts. You cannot install two applications with the same package on one device.
Note that you can always change the package name (and the label) under tools menu.

- Enter a package name.
- Next you will be asked to enter the application "label". This is the application name that the user will see.

Your program will now be compiled and installed to the emulator:



The emulator is significantly slower than a real device.
In many cases it is more convenient to work with a real device as the installation is much faster.

Note that you can always redeploy your program. There is no need to close the running program on the emulator.

Tracking the log with LogCat

Android devices keep an internal buffer of log messages. These messages can be very handy for debugging.

To view the logs you should switch to the LogCat tab in the right pane and press connect:


There are two "Hello world!" messages in the screenshot as I ran the program twice.
Unchecking "Filter" will show all available messages (not just messages relevant to your program).

Hello world

Common issues
- "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 error happens when you have non-ASCII characters in your Windows user name. Android SDK fails to find the proper path.
The solution is to create a folder named: c:\android
And to add an environment variable named ANDROID_SDK_HOME with the value of c:\android.

- "invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
Hint: use '@foo' to launch a virtual device named 'foo'." This error sometimes happen when you install Android SDK in a path with spaces. Copy the SDK to C:\Android and update the paths configuration to solve it.
- "javac: target release 1.5 conflicts with default source release 1.7" - Currently Basic4android requires Java 6. It will not work with Java 7. Both versions can be installed on the same computer.
Reply With Quote
  #2 (permalink)  
Old 11-03-2010, 08:48 AM
derez's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Posts: 978
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Erel
It looks easy !

What are the tools to control where in the device the application is located after installation (which folder ?).

What happens when you make an application that needs additional files (like images, sound, text files etc.) - how do you include them with the package for installation ?

Another issue - I am thinking of buying A81-E which uses a resistive screen, so it cannot handle multiple touch. How will the code handle the difference between capcitive screen and resistive ?

(more questions will follow until you give us work to do in the B4A...)
__________________
David Erez
Ramat Hasharon, Israel
Reply With Quote
  #3 (permalink)  
Old 11-03-2010, 09:17 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by derez View Post
What are the tools to control where in the device the application is located after installation (which folder ?).
You don't and can't. Android takes care of the details of installation and deinstallation. For 2.2 and later I believe there is an option to install a package on the SD card and not internally on the device but the package has to specifically permit this. B4A packages at the moment don't include this option.

Quote:
What happens when you make an application that needs additional files (like images, sound, text files etc.) - how do you include them with the package for installation ?
You place them in a folder in the B4A source tree and they are included as assets in the package that you can access from your code like a normal file.

Quote:
How will the code handle the difference between capcitive screen and resistive ?
It doesn't have to as there is no difference visible to either Android or your application.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #4 (permalink)  
Old 11-03-2010, 09:36 AM
derez's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Posts: 978
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Thank you
__________________
David Erez
Ramat Hasharon, Israel
Reply With Quote
  #5 (permalink)  
Old 11-12-2010, 10:27 PM
Senior Member
 
Join Date: Nov 2009
Posts: 153
Default Assets and memory overheads

>> What about files and images you wish to use during runtime?
Quote:
Originally Posted by agraham View Post
You place them in a folder in the B4A source tree and they are included as assets in the package that you can access from your code like a normal file.
.
Andrew, what happens if the program has a very large amount of these, say, MP3, JPG, TXT files? In a b4ppc program these would not affect the overall size of the program unless they were 'loaded'. Will including them as 'assets' in a b4a program increase its size massively?

Sarah
Reply With Quote
  #6 (permalink)  
Old 11-13-2010, 07:58 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I haven't worked out what really happens when an Android package is installed nor have I worked out how assets are accessed - whether from the apk as needed or whether extracted and saved - so can only comment in general terms.

Having a set of large assets in the package is probably undesirable as prior to Android 2.2 the apk is copied to the, usually limited amount of, internal device flash memory and installed there. The apk file is saved in flash memory, not deleted after app installation, and other data extracted from the apk is also saved. Having said this I see the popular AngryBirds game package is over 12Mbytes in size.

If an application requests and the user permits it on Android 2.2 and later an app can be installed on the SDcard. The Android docs say "The .apk file is saved on the external storage, but all private user data, databases, optimized .dex files, and extracted native code are saved on the internal device memory." Such an app can only run while the SDcard is mounted implying to me that assets are accessed from the apk as required.

The "Android" way of dealing with this would be to download the data from the cloud like most Google applications but not everyone has access to a 24/7 web server to host their data.

How Basic4Android applications are installed is something that will need thinking about.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #7 (permalink)  
Old 11-13-2010, 12:12 PM
Senior Member
 
Join Date: Nov 2009
Posts: 153
Default

Quote:
Originally Posted by agraham View Post
I haven't worked out what really happens when an Android package is installed nor have I worked out how assets are accessed - whether from the apk as needed or whether extracted and saved - so can only comment in general terms.

Having a set of large assets in the package is probably undesirable as prior to Android 2.2 the apk is copied to the, usually limited amount of, internal device flash memory and installed there. The apk file is saved in flash memory, not deleted after app installation, and other data extracted from the apk is also saved. Having said this I see the popular AngryBirds game package is over 12Mbytes in size.

If an application requests and the user permits it on Android 2.2 and later an app can be installed on the SDcard. The Android docs say "The .apk file is saved on the external storage, but all private user data, databases, optimized .dex files, and extracted native code are saved on the internal device memory." Such an app can only run while the SDcard is mounted implying to me that assets are accessed from the apk as required.

The "Android" way of dealing with this would be to download the data from the cloud like most Google applications but not everyone has access to a 24/7 web server to host their data.

How Basic4Android applications are installed is something that will need thinking about.
Thank you.

Some of my freeware nature applications use in excess of 90mb of data. With b4ppc I simply read in the small amount of data needed for each record. Android looks like it highly prefers web-based applications when data is in use.
Reply With Quote
  #8 (permalink)  
Old 11-13-2010, 12:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

On all Android devices I know of the SDcard looks like a USB memory stick to a desktop when the device is plugged in so you even if your app was installed from the Android Market it could look for the data on the SDcard and if missing prompt the user with a download link from which to obtain it.

If the application is to be downloaded from your own site then you just need two components, the apk for the application and a separate data package to copy to the SDcard of the device. I don't know if it is universal on Android devices but both my devices came with a File Manager that can look at the SDcard and if you click on an apk on the card will install it. Even if a device doesn't come with this ability then as long as it can access the market (not all devices, particularly tablets, can) there are many free installers and file managers that can do so. I use ES File Explorer which seems to be acknowledged as one of the best.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #9 (permalink)  
Old 12-09-2010, 03:26 AM
Junior Member
 
Join Date: Mar 2010
Posts: 28
Default Error ... Please Help

i have followed the instruction above, but i'm getting an error when the compiling the program. please see attached image for details.

any ideas ...

image link:
https://sites.google.com/site/ashandroid1/

thank you

Last edited by ashrafidkaidek : 12-09-2010 at 03:33 AM.
Reply With Quote
  #10 (permalink)  
Old 12-09-2010, 05:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Does adb.exe exist in the exact following path:
C:\Program Files\Android\android-sdk-windows\platform-tools
?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing Basic4android and Android SDK Erel Basic4android Getting started & Tutorials 38 03-28-2012 02:37 PM
Windows Mobile Emulator and Cellular Emulator ghale Tutorials 8 08-11-2009 03:06 PM
Installing into PPC mj19bg63 Questions (Windows Mobile) 2 05-18-2009 05:02 PM
"Hello World" = 3MB of memory & 6-8 seconds to load yairlanz Questions (Windows Mobile) 8 07-29-2008 10:15 AM
installing/uninstalling, CAB-file etc.. moster67 Questions (Windows Mobile) 5 06-09-2008 07:29 PM


All times are GMT. The time now is 10:11 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0