Thursday, June 16, 2011

android application **** has stopped unexpectedly try again. Android development

So I was working on my one of my first android apps and there were no errors but when I ran it I had the emulator telling me this: "Application ***** has stopped unexpectedly try again" then I had to force close it. I realized this happens a when some value is not set in the manifest file. In this my case it was the fact that the app would connect to Internet eventually and I had not set the Internet permissions correctly in the manifest file


So i added this line to on top of the application node in the android manifest xml file: <uses-permission android:name="android.permission.INTERNET" />



 A simple manifest file will look like this (the fix is i red):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Login"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>