Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse doesn't run android app when I click Run

Tags:

android

I'm trying to do the first app tutorial. After editing the 2 xml files, activity_main and strings, the instructions say, "In Eclipse, click Run from the toolbar."

First off, it showed me some problems. With the EditText set to android:layout_weight="1", it doesn't like the android:layout_height set to wrap_content and shows me on the Problems tab. The problem goes away if I set layout_height to 0dp like the width.

Second, now that it shows me nothing in the problems list, hitting run doesn't do anything, either on the windows computer or on my android device connected via usb and set up according to the previous instructions.

I found another thread with similar question. They suggested he look at his AndroidManifest.xml and MainActivity.java. Mine seem to contain what they suggested needed to be there. Oh! I see my avid is open, but it doesn't seem to say anything.

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
    <EditText android:id = "@+id/edit_message"
        android:layout_weight="1"
        android:layout_width = "0dp"
        android:layout_height = "0dp"
        android:hint="@string/edit_message"/>
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text = "@string/button_send"/>
</LinearLayout>

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">My First App</string>
    <string name="action_settings">Settings</string>
    <string name="edit_message">Edit your message, silly.</string>
    <string name="button_send">Send</string>
    <string name="title_activity_man">MainActivity</string>

</resources>
like image 980
Tom the Newb Avatar asked Feb 04 '26 01:02

Tom the Newb


2 Answers

The Run button in Eclipse doesn't function when you're on an XML file. Open up one of the .java files, then hit Run - it should compile and run the app.

like image 92
Dan Amato Avatar answered Feb 05 '26 15:02

Dan Amato


Create an AVD for using emulator or make sure your phone is detected by eclipse. Also go to Run Configurations,create a new configuration for Android Application and select your Android project.

like image 35
user2125722 Avatar answered Feb 05 '26 15:02

user2125722