• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help needed! Build-errors with Hello World!

This is most sad:
When trying to run the Hello World-project from Hello, World | Android Developers in Eclipse
Version: 3.4.2
Build id: M20090211-1700
I get the following errors:

Code:
Description    Resource    Path    Location    Type
Class com.example.helloandroid.helloandroid does not exist    AndroidManifest.xml    HelloAndroid    line 8    Android XML Content Problem
Class com.example.helloandroid.helloandroid does not exist    AndroidManifest.xml    HelloAndroidv2    line 8    Android XML Content Problem
Class com.magicmojo.helloworldtut.HelloAndroidTut does not exist    AndroidManifest.xml    HelloWorld tut    line 8    Android XML Content Problem
The declared package "com.android.helloandroid" does not match the expected package "com.example.helloandroid"    helloandroid.java    HelloAndroid/src/com/example/helloandroid    line 1    Java Problem
The declared package "com.android.helloandroid" does not match the expected package "com.example.helloandroid"    helloandroid.java    HelloAndroidv2/src/com/example/helloandroid    line 1    Java Problem
The public type HelloAndroid must be defined in its own file    HelloAndroidTut.java    HelloWorld tut/src/com/magicmojo/helloworldtut    line 7    Java Problem
The public type HelloAndroid must be defined in its own file    helloandroid.java    HelloAndroid/src/com/example/helloandroid    line 7    Java Problem
The public type HelloAndroid must be defined in its own file    helloandroid.java    HelloAndroidv2/src/com/example/helloandroid    line 7    Java Problem
Code:
I also got these console-messages:
[2010-11-11 16:01:40 - HelloAndroid] Android Launch!
[2010-11-11 16:01:40 - HelloAndroid] adb is running normally.
[2010-11-11 16:01:40 - HelloAndroid] Performing com.example.helloandroid.helloandroid activity launch
[2010-11-11 16:01:40 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'Mijn_AVD2'
[2010-11-11 16:01:40 - HelloAndroid] Launching a new emulator with Virtual Device 'Mijn_AVD2'
[2010-11-11 16:01:40 - Emulator] emulator: ERROR: unknown virtual device name: 'Mijn_AVD2'
[2010-11-11 16:01:40 - Emulator] emulator: could not find virtual device named 'Mijn_AVD2'
Mijn_AVD2 is Dutch for My_AVD2. I only just created the AVD, running the ANdroid.bat-tool shows that it really does exist.
Before I froget: this is the code:
Code:
package com.android.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android- tv.SetText");
       setContentView(tv);
   }
}
 
There seems to be a couple of different problems going on here, based on the outputs you've provided. One problem I noticed from the first set of output, is:

declared package "com.android.helloandroid" does not match the expected package "com.example.helloandroid"
What package/directory is helloandroid.java sitting in under Eclipse? (you should be able to see by expanding the "src" node in the Project Explorer tab in Eclipse) If it is in com.example.helloandroid instead of com.android.helloandroid, there are a couple of ways you can fix this error. You can either change the first line of HelloAndroid.java to reflect the correct package, or you can right-click on the package node and go to Refractor->Rename.

The second problem I noticed from the first set of output is:
public type HelloAndroid must be defined in its own file helloandroid.java
The problem here is the name of the .java file is spelled differently than the class name (case-sensitive problem). To fix this, either change the name of the class or the name of the .java file so they match.

The third problem I noticed from the first set of output (related to the two above problems):
... HelloAndroidv2/src/com/example/helloandroid ...
You seem to have two versions of HelloAndroid. If they are in seperate packages, that is fine, just make sure to check the two things I mentioned above (package/directory structure matches whats in the first line of the .java file, and the name of the .java file is spelled the same as the class name inside that .java file). If you only have one project rather than two projects, you'll want to remove one of the copies.

BTW, Let me know if you are not familiar with Eclipse projects and have no idea what I'm talking about - I can provide screen-shots to help if necessary.

With regards to your second set of output, could you load up the Andriod AVD Manager and check what AVDs you have created. If one with that name is listed, try running it from the AVD Manager and see if there are any problems. If it loads fine, then try compiling and running your project (after you correct the errors mentioned above) and see if you still get the same error outputs.
 
  • Like
Reactions: Dutchmarco
Upvote 0
Hi, thanks for the tip. I've been mucking about a fair bit (and I don't recall exactly all that I've done), now I get fewer errors/problems.One problem is I copied straight from the tutorial, and that's where com.android.helloandroid got mangled from the com.example.helloandroid.

However, I now get the following:
Code:
[2010-11-12 15:57:15 - HelloAndroid] ------------------------------
[2010-11-12 15:57:15 - HelloAndroid] Android Launch!
[2010-11-12 15:57:15 - HelloAndroid] adb is running normally.
[2010-11-12 15:57:15 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch
[2010-11-12 15:57:15 - HelloAndroid] Failed to find an AVD compatible with target 'Android 1.5'.
[2010-11-12 15:57:53 - SDK Manager] Created AVD 'HelloAVD' based on Android 1.5,
[2010-11-12 15:57:53 - SDK Manager] with the following hardware config:
[2010-11-12 15:57:53 - SDK Manager] hw.sdCard=yes
[2010-11-12 15:58:01 - HelloAndroid] Still no compatible AVDs with target 'Android 1.5': Aborting launch.
[2010-11-12 15:58:01 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch
[2010-11-12 15:59:19 - HelloAndroid] Launching a new emulator with Virtual Device 'HelloAVD'
[2010-11-12 15:59:19 - Emulator] emulator: ERROR: unknown virtual device name: 'HelloAVD'
[2010-11-12 15:59:19 - Emulator] emulator: could not find virtual device named 'HelloAVD'

I've been trying to solve this., but I keep getting the errors.
Sorry to keep nagging, but this is getting bizarre. In the past, I have managed to run the Hello World app fine, in an amulator, on this PC, but I don't know what's changed (appart from the elapsed time between that first time and this one).

Thanks for your help, this is getting encouraging.
 
Upvote 0
Could you load up the Android AVD Manager (under the "Window" menu in Eclipse) and list all the AVDs? I'm guessing there either are no AVDs created at all, or at least there isn't one named "HelloAVD". If there is one named HelloAVD, start it from the Android AVD Manager while you are there, and after it finishes booting up, try running your project to see if it works. If there isn't an AVD named HelloAVD, then create one there while you have the Android AVD Manager up.
 
Upvote 0
Thanks for the help. The AVD does exist - but it cannot be started (not even manually from within the AVD mgr), I just select it, press start and get a popup with config options (HVGA etc), OK that and get another one with progress bar and the following messages:

emulator: ERROR: unknown virtual device name: 'HelloAVD'
emulator: could not find virtual device named 'HelloAVD'

All devices are OK (green check)
 
Upvote 0
Sorry if this shows up as a double post, but I don't think I hit the Submit Post button in time before my internet cut out.

Anyway, this message is usually related to Android creating the AVD in a different directory than the emulator is looking. This can happen if you moved your home directory, or if you are logged into a domain account. If we're talking about Windows, the emulator may be looking in C:\Users\<username>\.android while the AVD is actually in C:\Users\<domain>.<username>\.android or in D:\.android.

Try searching around on your hard drive(s), and if you find that you have something like this going on, you can either copy the folder contents from one location to the other, or set up a symbolic link so both paths point to the same actual folder.

If that's not the problem, you could try deleting the AVD and recreating it from the AVD Manager, in case it is corrupt or something.
 
  • Like
Reactions: Dutchmarco
Upvote 0
Thanks Paul.

Sadly that didn't solve the issue (yet). Could you give me a printlisting of the dir structure on your PC? (I'm presuming you have Windows, i spite of your talking about symlinks which makes me think you're actually using Linux.

These are the contents of my .android-directory:

K:\D\Win-meuk\.android\adb_usb.ini
K:\D\Win-meuk\.android\add-ons
K:\D\Win-meuk\.android\android-sdk-windows
K:\D\Win-meuk\.android\androidtool.cfg
K:\D\Win-meuk\.android\avd
K:\D\Win-meuk\.android\ddms.cfg
K:\D\Win-meuk\.android\debug.keystore
K:\D\Win-meuk\.android\docs
K:\D\Win-meuk\.android\market_licensing
K:\D\Win-meuk\.android\platforms
K:\D\Win-meuk\.android\repositories.cfg
K:\D\Win-meuk\.android\samples
K:\D\Win-meuk\.android\SDK android-sdk_r07-windows
K:\D\Win-meuk\.android\SDK Manager.exe
K:\D\Win-meuk\.android\SDK Readme.txt
K:\D\Win-meuk\.android\temp
K:\D\Win-meuk\.android\tools
K:\D\Win-meuk\.android\usb_driver

As you can see, I've copied the SDK willy-nilly into the directory (both the subdirs separately as well as in their own dir
(K:\D\Win-meuk\.android\SDK android-sdk_r07-windows\android-sdk-windows
and
K:\D\Win-meuk\.android\android-sdk-windows)

K:\D\Win-meuk\.android\ is the AVD-directory (I didn't know that, you install and learn/reinstall...

This is on my main PC, the AVDs work OK on my laptop (which is slooow! Thus I prefer to be able to develop on my faster one.)
 
Upvote 0
Sadly, I can't help you out with a working directory structure.. I use Linux as you noticed by my reference to" symbolic link" (What does Microsoft call them "NTFS Junction" I think.) Anyway, your directory structure definitely looks like the culperate. Do you have access too the C drive? You could try the symbolic link at the usual Windows home directory path pointing to the actual home directory.
 
  • Like
Reactions: Dutchmarco
Upvote 0
I performed this:
junction c:\users\marco\.android K:\D\dev\Android\android-sdk_r07-windows\android-sdk-windows
The junction WAS created but I think I made a mistake, amking it point to the wrong directory. Try as I might, I seem unable to delete the junction (I use junction -d \c:\users\marco\.android but junction.exe only prints some usage info. Of course, still no luck in running an AVD. That does workon my laptop, but I keep getting the msg of waiting for HOMeE to start, apparantly that takes a very long time to load on such a slow CPU.
Oh well, guess I'll have to develop without using an emulator, just copy the darn APK to my phone every time I've developed something. I guess the other option is to reinstall Windoze on C:\ and apart from having lots of stuff to reinstall, that means I won't have to make do with such a non-standard system anymore. 'Cause if there's anything Microshaft can't stand it's any deviation from their standards. Thanks for all your help, though!
 
Upvote 0
Yes, I think you pointed the junction to the wrong place. From what I've read, in your case (assuming your username is marco and the avd directory is under K:\D\Win-meuk\.android) you would want the Junction to point from C:\Users\marco\.android to K:\D\Win-meuk\.android (notice the capital "U" in C:\Users)

I assume you are using Windows Vista or Windows 7, based on the lack of the "Documents and Settings" directory. From Vista and 7, you can safely delete the junction via Windows Explorer (i.e., just select the icon and press "Delete").

For anyone else reading this thread, if you are using a previous version of windows, deleting a junction from Windows Explorer will also delete the target directory and all its subdirectories (could be used as a last resort - it would require backing up the contents of the target directory and then restoring them after the delete).

If Dutchmarco were using Windows 2000 or XP, he would be able to safely delete the junction with either of the following commands:
linkd C:\users\marco\.android /d
or:
Delrp C:\users\marco\.android

And he could create the correct junction (Windows 2000 or XP):
linkd C:\"Documents and Settings"\marco\.android K:\D\Win-meuk\.android
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones