Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Android Test Project does not start

Tags:

android

I'm creating my first android application but it does not start at all.

In my src > android.SampleApp I created a java file named Main.java with:

public class Main extends Activity {

// Will be connected with the buttons via XML
public void myClickHandler(View view) {
    switch (view.getId()) {
    case R.id.btn1:
        ((EditText) findViewById(R.id.txtContent)).setText("Button 1 Clicked");
        break;
    case R.id.btn2:
        ((EditText) findViewById(R.id.txtContent)).setText("Button 2 Clicked");
        break;

    }
}
}

In my res > layout > main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" android:id="@+id/txtContent"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button One" android:id="@+id/btn1"></Button>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button Two" android:id="@+id/btn2"></Button>

My AndroidManifest.xml content:

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="android.SampleApp"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">


</application>
<uses-sdk android:minSdkVersion="7" />

I get this error:

  1. [2010-02-02 01:46:26 - SampleApp]Android Launch!
  2. [2010-02-02 01:46:26 - SampleApp]adb is running normally.
  3. [2010-02-02 01:46:26 - SampleApp]No Launcher activity found!
  4. [2010-02-02 01:46:26 - SampleApp]The launch will only sync the application package on the device!
  5. [2010-02-02 01:46:26 - SampleApp]Performing sync

Lines 3 and 4 is highlighted red.

Could someone lead my in the right direction to just get the application to show on the emulator?

Android 2.1 SDK with Eclipse

like image 677
Shawn Mclean Avatar asked Feb 02 '10 18:02

Shawn Mclean


People also ask

How do I connect my Android to test project?

Using an appropriate USB cable, you can plug it into any device with a TestProject agent in order to start using it. When you do that you should get a popup asking you to authorize the device for use with TestProject. Select yes on this and you can start creating your first Android test.

How to find test coverage in Android Studio?

Android Studio has a built-in feature that allows you to run tests with code coverage. Simply navigate to the src/test/java folder and right click. Then select Run 'Tests in 'java'' with Coverage (awkward use of single quotes theirs not mine).


1 Answers

You are missing the following in your <activity> tag in your manifest file:

        <intent-filter . . . >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

For more info see here

like image 84
Mark B Avatar answered Nov 14 '22 21:11

Mark B