Sign in to follow this  
NUCLEAR RABBIT

First adroid app wont work *SOLVED*

Recommended Posts

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!");
			}
		});
		
		
	}
}

 

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

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.

Edited by dsm1891

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites


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>
 

Share this post


Link to post
Share on other sites

 

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!

Share this post


Link to post
Share on other sites

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);
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this