First adroid app wont work *SOLVED*

Started by
6 comments, last by adt7 11 years ago

Hello, So I coded a portion of my first app, its not 100% done, but I wanted to test what I had learned thus far. Im coding in eclipse, have no errors and i load up my emulator. I cant find the app icon on the phone, but if I click on the emulator and go to applications/sd& applications/manage applications/downloaded it shows up there and when I click it, I dont have an option to open it, just uninstall. Can anyone please help me understand why this is occuring?! been trying to get this going for 2 days :|

MainActivity.java


package com.bwall.thenumbergame;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.view.View;
import com.bwall.thenumbergame.R;

public class MainActivity extends Activity {
	
	int number = 0;
	
	TextView textField = (TextView) findViewById(R.id.textField);
	TextView result = (TextView) findViewById(R.id.resultView);
	EditText gameObjective = (EditText) findViewById(R.string.gameObjective);
	Button button = (Button) findViewById(R.string.submitButton);
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				number = textField.getInputType();
				result.setText("Your Number is " + number + ", bitch!");
			}
		});
		
		
	}
}

Advertisement

Include the intent filter in ur Androidmanifest file for your main activity


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

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

if ^ doesn't work (and assuming you are running eclipse, Re-run the emulator, I, and many of my friends found, that there can be a slight bug with the emulator where it seems to run a previous instance of it self, I.E. before you made that app, thus it not showing

--edit--

:/ sorry, just re-read you post, prob wont be this, but ill leave it here, for future reference, because its darn annoying.

Mobile Developer at PawPrint Games ltd.

(Not "mobile" as in I move around a lot, but as in phones, mobile phone developer)

(Although I am mobile. no, not as in a babies mobile, I move from place to place)

(Not "place" as in fish, but location.)

Include the intent filter in ur Androidmanifest file for your main activity


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

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

I tried adding this to the androidmanifiest file but still no luck :(


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bwall.thenumbergame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.bwall.thenumbergame.MainActivity"
            android:label="@string/title_activity_main" >
        </activity>

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

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

</manifest>

Include the intent filter in ur Androidmanifest file for your main activity


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

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

I tried adding this to the androidmanifiest file but still no luck sad.png


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bwall.thenumbergame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.bwall.thenumbergame.MainActivity"
            android:label="@string/title_activity_main" >
        </activity>

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

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

</manifest>

Also shows this in the debugger

ScreenShot2013-04-04at115429AM.png


Include the intent filter in ur Androidmanifest file for your main activity

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

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



I tried adding this to the androidmanifiest file but still no luck sad.png


That's because it needs to go *inside* the activity node, like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bwall.thenumbergame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.bwall.thenumbergame.MainActivity"
            android:label="@string/title_activity_main" >

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

</manifest>
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

Include the intent filter in ur Androidmanifest file for your main activity

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

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



I tried adding this to the androidmanifiest file but still no luck sad.png

That's because it needs to go *inside* the activity node, like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bwall.thenumbergame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.bwall.thenumbergame.MainActivity"
            android:label="@string/title_activity_main" >

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

</manifest>

Thanks a BUNCH! biggrin.png

just got to figure out why it exits right when I start the app now! Exits unexpectedly...Ill be back if I cannot figure this problem out!

It exits unexpectedly because the following lines of code need to be moved to onCreate, after the call to SetContentView.


TextView textField = (TextView) findViewById(R.id.textField);
TextView result = (TextView) findViewById(R.id.resultView);
EditText gameObjective = (EditText) findViewById(R.string.gameObjective);
Button button = (Button) findViewById(R.string.submitButton);
 

This topic is closed to new replies.

Advertisement