Unfortunately <appname> has stopped - java

I have seen many similar questions to this one posted on SO but none seem to answer my question. Quite simply, every time I try and run my app on the emulator, it quits back to the main menu and displays a dialog saying "Unfortunatley, Scribble Runner has stopped". Here is my BaseActivity class and my AndroidManifest.xml file.
BaseActivity:
import java.io.IOException;
import java.io.InputStream;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.util.FPSLogger;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.font.FontFactory;
import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.bitmap.BitmapTexture;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.texture.region.TextureRegionFactory;
import org.andengine.ui.activity.SimpleBaseGameActivity;
import org.andengine.util.adt.io.in.IInputStreamOpener;
import org.andengine.util.debug.Debug;
import android.util.Log;
public class BaseActivity extends SimpleBaseGameActivity {
//CONSTANTS AND FIELDS
public static int CAMERA_WIDTH = 720;
public static int CAMERA_HEIGHT = 480;
public Font mFont;
public Camera mCamera;
private ITextureRegion mBackgroundTextureRegion, mEnemyTextureRegion;
private BitmapTextureAtlas mAutoParallaxBackgroundTexture;
private TextureRegion mParallaxLayerFront;
private TextureRegion mParallaxLayerMid;
private TextureRegion mParallaxLayerBack;
public Scene mCurrentScene;
public static BaseActivity instance;
#Override
public EngineOptions onCreateEngineOptions() {
instance = this;
mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
System.out.println("Engine Created");
return new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new
RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
}
#Override
protected void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
try{
this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1024);
this.mParallaxLayerFront = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "parallax_background_layer_front.png", 0, 0);
this.mParallaxLayerBack = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "parallax_background_layer_back.png", 0, 188);
this.mParallaxLayerMid = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "parallax_background_layer_mid.png", 0, 669);
this.mAutoParallaxBackgroundTexture.load();
System.out.println("Resources Created");
}catch(Exception e){
Debug.e(e);
}
}
#Override
protected Scene onCreateScene() {
mEngine.registerUpdateHandler(new FPSLogger());
mCurrentScene = new Scene();
Sprite backgroundSprite1 = new Sprite(0, 0, this.mParallaxLayerBack, getVertexBufferObjectManager());
Sprite backgroundSprite2 = new Sprite(0, 0, this.mParallaxLayerMid, getVertexBufferObjectManager());
Sprite backgroundSprite3 = new Sprite(0, 0, this.mParallaxLayerFront, getVertexBufferObjectManager());
mCurrentScene.attachChild(backgroundSprite1);
mCurrentScene.attachChild(backgroundSprite2);
mCurrentScene.attachChild(backgroundSprite3);
System.out.println("Scene Created");
return mCurrentScene;
}
public static BaseActivity getSharedInstance(){
return instance;
}
//change the current main scene
public void setCurrentScene(Scene scene){
mCurrentScene = scene;
getEngine().setScene(mCurrentScene);
}
}
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.provisionalsolutions.scribblerunner"
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.provisionalsolutions.scribblerunner.BaseActivity"
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>
And here is the LogCat:
02-06 13:41:21.664: W/ActivityManager(275): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
02-06 13:41:21.674: W/Trace(589): Unexpected value from nativeGetEnabledTags: 0
02-06 13:41:21.697: E/ActivityThread(589): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40cf2458 that was originally bound here
02-06 13:41:21.697: E/ActivityThread(589): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40cf2458 that was originally bound here
02-06 13:41:21.697: E/ActivityThread(589): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
02-06 13:41:21.697: E/ActivityThread(589): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
02-06 13:41:21.697: E/ActivityThread(589): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
02-06 13:41:21.697: E/ActivityThread(589): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
02-06 13:41:21.697: E/ActivityThread(589): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
02-06 13:41:21.697: E/ActivityThread(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
02-06 13:41:21.697: E/ActivityThread(589): at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-06 13:41:21.697: E/ActivityThread(589): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-06 13:41:21.697: E/ActivityThread(589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-06 13:41:21.697: E/ActivityThread(589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-06 13:41:21.697: E/ActivityThread(589): at java.lang.Thread.run(Thread.java:856)
02-06 13:41:21.714: E/StrictMode(589): null
02-06 13:41:21.714: E/StrictMode(589): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40cf2458 that was originally bound here
02-06 13:41:21.714: E/StrictMode(589): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
02-06 13:41:21.714: E/StrictMode(589): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
02-06 13:41:21.714: E/StrictMode(589): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
02-06 13:41:21.714: E/StrictMode(589): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
02-06 13:41:21.714: E/StrictMode(589): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
02-06 13:41:21.714: E/StrictMode(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
02-06 13:41:21.714: E/StrictMode(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
02-06 13:41:21.714: E/StrictMode(589): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
02-06 13:41:21.714: E/StrictMode(589): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
02-06 13:41:21.714: E/StrictMode(589): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
02-06 13:41:21.714: E/StrictMode(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
02-06 13:41:21.714: E/StrictMode(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
02-06 13:41:21.714: E/StrictMode(589): at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-06 13:41:21.714: E/StrictMode(589): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-06 13:41:21.714: E/StrictMode(589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-06 13:41:21.714: E/StrictMode(589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-06 13:41:21.714: E/StrictMode(589): at java.lang.Thread.run(Thread.java:856)
02-06 13:41:21.714: W/ActivityManager(275): Unbind failed: could not find connection for android.os.BinderProxy#40e80c68
02-06 13:41:21.724: E/ActivityThread(589): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40d19e88 that was originally bound here
02-06 13:41:21.724: E/ActivityThread(589): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40d19e88 that was originally bound here
02-06 13:41:21.724: E/ActivityThread(589): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
02-06 13:41:21.724: E/ActivityThread(589): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
02-06 13:41:21.724: E/ActivityThread(589): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
02-06 13:41:21.724: E/ActivityThread(589): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
02-06 13:41:21.724: E/ActivityThread(589): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
02-06 13:41:21.724: E/ActivityThread(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
02-06 13:41:21.724: E/ActivityThread(589): at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-06 13:41:21.724: E/ActivityThread(589): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-06 13:41:21.724: E/ActivityThread(589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-06 13:41:21.724: E/ActivityThread(589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-06 13:41:21.724: E/ActivityThread(589): at java.lang.Thread.run(Thread.java:856)
02-06 13:41:21.734: E/StrictMode(589): null
02-06 13:41:21.734: E/StrictMode(589): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40d19e88 that was originally bound here
02-06 13:41:21.734: E/StrictMode(589): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
02-06 13:41:21.734: E/StrictMode(589): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
02-06 13:41:21.734: E/StrictMode(589): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
02-06 13:41:21.734: E/StrictMode(589): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
02-06 13:41:21.734: E/StrictMode(589): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
02-06 13:41:21.734: E/StrictMode(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
02-06 13:41:21.734: E/StrictMode(589): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
02-06 13:41:21.734: E/StrictMode(589): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
02-06 13:41:21.734: E/StrictMode(589): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
02-06 13:41:21.734: E/StrictMode(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
02-06 13:41:21.734: E/StrictMode(589): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
02-06 13:41:21.734: E/StrictMode(589): at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-06 13:41:21.734: E/StrictMode(589): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-06 13:41:21.734: E/StrictMode(589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-06 13:41:21.734: E/StrictMode(589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-06 13:41:21.734: E/StrictMode(589): at java.lang.Thread.run(Thread.java:856)
here is another part of the stack trace showing errors:
02-06 13:45:37.300: E/AndroidRuntime(815): FATAL EXCEPTION: main
02-06 13:45:37.300: E/AndroidRuntime(815): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.provisionalsolutions.scribblerunner/com.provisionalsolutions.scribblerunner.BaseActivity}: java.lang.ClassNotFoundException: Didn't find class "com.provisionalsolutions.scribblerunner.BaseActivity" on path: /data/app/com.provisionalsolutions.scribblerunner-2.apk
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.os.Looper.loop(Looper.java:137)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-06 13:45:37.300: E/AndroidRuntime(815): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 13:45:37.300: E/AndroidRuntime(815): at java.lang.reflect.Method.invoke(Method.java:511)
02-06 13:45:37.300: E/AndroidRuntime(815): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-06 13:45:37.300: E/AndroidRuntime(815): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-06 13:45:37.300: E/AndroidRuntime(815): at dalvik.system.NativeStart.main(Native Method)
02-06 13:45:37.300: E/AndroidRuntime(815): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.provisionalsolutions.scribblerunner.BaseActivity" on path: /data/app/com.provisionalsolutions.scribblerunner-2.apk
02-06 13:45:37.300: E/AndroidRuntime(815): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-06 13:45:37.300: E/AndroidRuntime(815): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-06 13:45:37.300: E/AndroidRuntime(815): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
02-06 13:45:37.300: E/AndroidRuntime(815): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
02-06 13:45:37.300: E/AndroidRuntime(815): ... 11 more

02-06 13:41:21.664: W/ActivityManager(275): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
02-06 13:41:21.674: W/Trace(589): Unexpected value from nativeGetEnabledTags: 0
this tells you, you have a problem with an intent... in your posted code is no intent, so i think the problem belongs to another part of your program ^^

Related

Why does my Android project crash?

I am writing an Android application in Eclipse that uses RitaWordNet to find synonyms for a word. It compiles but on running it crashes. Is it possible that the app crashes and I receive the message "Unfortunately RitaWord has stopped working". Is it because the jar files I have added to the build path to make the app work are so large (>10 MB)? The program is:
package com.example.ritaword;
import java.util.Arrays;
import android.*
import rita.wordnet.*;
public class MainActivity extends Activity {
TextView A, B;
Button ok;
String[] synonyms;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ok = (Button)findViewById(android.R.id.button1);
A = (TextView)findViewById(R.id.textView1);
B = (TextView)findViewById(R.id.textView2);
B.setText("");
RiWordnet wordnet = new RiWordnet();
String word = wordnet.getRandomWord("a");
synonyms = wordnet.getAllSynonyms(word, "a", 1);
}
public void onClick(View view) {
switch (view.getId()) {
case (R.id.button1):
if (synonyms != null) {
Arrays.sort(synonyms);
B.setText(synonyms[0]);
}
else
B.setText("No synyonyms!");
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
If it helps, the last few error Logs I receive are:
>04-20 22:25:08.239: E/ActivityThread(730): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
04-20 22:25:08.239: E/ActivityThread(730): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
04-20 22:25:08.239: E/ActivityThread(730): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-20 22:25:08.239: E/ActivityThread(730): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-20 22:25:08.239: E/ActivityThread(730): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-20 22:25:08.239: E/ActivityThread(730): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-20 22:25:08.239: E/ActivityThread(730): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-20 22:25:08.239: E/ActivityThread(730): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-20 22:25:08.239: E/ActivityThread(730): at java.lang.Thread.run(Thread.java:856)
04-20 22:25:08.319: E/StrictMode(730): null
04-20 22:25:08.319: E/StrictMode(730): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection#40cea428 that was originally bound here
04-20 22:25:08.319: E/StrictMode(730): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
04-20 22:25:08.319: E/StrictMode(730): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
04-20 22:25:08.319: E/StrictMode(730): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
04-20 22:25:08.319: E/StrictMode(730): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
04-20 22:25:08.319: E/StrictMode(730): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
04-20 22:25:08.319: E/StrictMode(730): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
04-20 22:25:08.319: E/StrictMode(730): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
04-20 22:25:08.319: E/StrictMode(730): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
04-20 22:25:08.319: E/StrictMode(730): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
04-20 22:25:08.319: E/StrictMode(730): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
04-20 22:25:08.319: E/StrictMode(730): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-20 22:25:08.319: E/StrictMode(730): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-20 22:25:08.319: E/StrictMode(730): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-20 22:25:08.319: E/StrictMode(730): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-20 22:25:08.319: E/StrictMode(730): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-20 22:25:08.319: E/StrictMode(730): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-20 22:25:08.319: E/StrictMode(730): at java.lang.Thread.run(Thread.java:856)

having error "Unfortunately you ### application has stopped"

This is a food recipe application and I am just learning so if you could please help me rectify my error and explain, I will be so grateful. Thanks in advance
Main activity
package rice.recipe;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;
public class RiceActivity extends Activity {
private RiceRecipeDataSource ds;
private ListView recipelistview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rice);
ds=new RiceRecipeDataSource();
recipelistview=(ListView)findViewById(rice.recipe.R.id.listView1);
recipelistview.setAdapter(new RiceRecipeDataSourceAdapter(this,ds ));
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.rice, menu);
return true;
}
}
ADAPTER code
package rice.recipe;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class RiceRecipeDataSourceAdapter extends BaseAdapter {
private Context mycontext;
private LayoutInflater myinflater;
private RiceRecipeDataSource mydatasource;
public RiceRecipeDataSourceAdapter(Context ctx,RiceRecipeDataSource ds)
{
mycontext=ctx;
mydatasource=ds;
myinflater=(LayoutInflater)mycontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return mydatasource.getDataSourceLength();
}
#Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView thumbnail;
TextView name;
if (convertView==null)
convertView=myinflater.inflate(rice.recipe.R.layout.activity_rice, parent,false);
thumbnail=(ImageView)convertView.findViewById(rice.recipe.R.id.imageView1);
thumbnail.setImageResource(mydatasource.getPhotoPool().get(position));
name=(TextView)convertView.findViewById((rice.recipe.R.id.textView1));
name.setText(mydatasource.getDishesPool().get(position));
return convertView;
}
}
DATA SOURCE code
package rice.recipe;
import java.util.ArrayList;
public class RiceRecipeDataSource
{
private ArrayList<Integer> photoPool;
private ArrayList<Integer> descriptionPool;
private ArrayList<Integer> dishesPool;
public ArrayList<Integer> getPhotoPool()
{
return photoPool;
}
public ArrayList<Integer> getDescriptionPool()
{
return descriptionPool;
}
public ArrayList<Integer> getDishesPool()
{
return dishesPool;
}
public RiceRecipeDataSource()
{
photoPool=new ArrayList<Integer>();
descriptionPool=new ArrayList<Integer>();
dishesPool=new ArrayList<Integer>();
setupPhotopool();
setupDescriptionpool();
setupDishespool();
}
public void setupPhotopool()
{
photoPool.add(rice.recipe.R.drawable.jollofrice);
photoPool.add(rice.recipe.R.drawable.friedrice);
photoPool.add(rice.recipe.R.drawable.spaghetti);
photoPool.add(rice.recipe.R.drawable.coconutrice);
photoPool.add(rice.recipe.R.drawable.ricenbeans);
photoPool.add(rice.recipe.R.drawable.whiterice);
}
public void setupDishespool()
{
dishesPool.add(rice.recipe.R.string.jellof);
dishesPool.add(rice.recipe.R.string.fried_rice);
dishesPool.add(rice.recipe.R.string.spag);
dishesPool.add(rice.recipe.R.string.coconut);
dishesPool.add(rice.recipe.R.string.rice_beans);
dishesPool.add(rice.recipe.R.string.plain_rice);
}
public void setupDescriptionpool()
{
descriptionPool.add(rice.recipe.R.string.jellof_desc);
descriptionPool.add(rice.recipe.R.string.friedr_desc);
descriptionPool.add(rice.recipe.R.string.spag_desc);
descriptionPool.add(rice.recipe.R.string.coconut_desc);
}
public int getDataSourceLength()
{
return photoPool.size();
}
}
This is my LogCat
04-03 05:47:34.217: D/dalvikvm(865): GC_FOR_ALLOC freed 39K, 6% free 2657K/2816K, paused 78ms, total 83ms
04-03 05:47:34.237: I/dalvikvm-heap(865): Grow heap (frag case) to 3.783MB for 1127536-byte allocation
04-03 05:47:34.317: D/dalvikvm(865): GC_FOR_ALLOC freed 2K, 5% free 3756K/3920K, paused 80ms, total 80ms
04-03 05:47:34.421: D/dalvikvm(865): GC_CONCURRENT freed <1K, 5% free 3760K/3920K, paused 13ms+20ms, total 108ms
04-03 05:47:34.697: D/AndroidRuntime(865): Shutting down VM
04-03 05:47:34.697: W/dalvikvm(865): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-03 05:47:34.778: E/AndroidRuntime(865): FATAL EXCEPTION: main
04-03 05:47:34.778: E/AndroidRuntime(865): java.lang.NullPointerException
04-03 05:47:34.778: E/AndroidRuntime(865): at rice.recipe.RiceRecipeDataSourceAdapter.getView(RiceRecipeDataSourceAdapter.java:52)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.ListView.onMeasure(ListView.java:1158)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.View.measure(View.java:15518)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.RelativeLayout.measureChild(RelativeLayout.java:666)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.View.measure(View.java:15518)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.View.measure(View.java:15518)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.View.measure(View.java:15518)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-03 05:47:34.778: E/AndroidRuntime(865): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.View.measure(View.java:15518)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.Choreographer.doFrame(Choreographer.java:532)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.os.Handler.handleCallback(Handler.java:725)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.os.Looper.loop(Looper.java:137)
04-03 05:47:34.778: E/AndroidRuntime(865): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-03 05:47:34.778: E/AndroidRuntime(865): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 05:47:34.778: E/AndroidRuntime(865): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 05:47:34.778: E/AndroidRuntime(865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-03 05:47:34.778: E/AndroidRuntime(865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-03 05:47:34.778: E/AndroidRuntime(865): at dalvik.system.NativeStart.main(Native Method)
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="rice.recipe"
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="rice.recipe.RiceActivity"
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>
after editing, new logcat
04-03 07:23:36.608: D/dalvikvm(933): GC_FOR_ALLOC freed 46K, 6% free 2657K/2824K, paused 175ms, total 179ms
04-03 07:23:36.631: I/dalvikvm-heap(933): Grow heap (frag case) to 3.783MB for 1127536-byte allocation
04-03 07:23:36.709: D/dalvikvm(933): GC_FOR_ALLOC freed 2K, 5% free 3756K/3928K, paused 75ms, total 75ms
04-03 07:23:36.858: D/dalvikvm(933): GC_CONCURRENT freed <1K, 4% free 3771K/3928K, paused 13ms+19ms, total 153ms
04-03 07:23:37.161: D/AndroidRuntime(933): Shutting down VM
04-03 07:23:37.161: W/dalvikvm(933): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-03 07:23:37.248: E/AndroidRuntime(933): FATAL EXCEPTION: main
04-03 07:23:37.248: E/AndroidRuntime(933): java.lang.NullPointerException
04-03 07:23:37.248: E/AndroidRuntime(933): at rice.recipe.RiceRecipeDataSourceAdapter.getView(RiceRecipeDataSourceAdapter.java:52)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.ListView.onMeasure(ListView.java:1158)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.View.measure(View.java:15518)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.RelativeLayout.measureChild(RelativeLayout.java:666)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.View.measure(View.java:15518)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.View.measure(View.java:15518)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.View.measure(View.java:15518)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-03 07:23:37.248: E/AndroidRuntime(933): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.View.measure(View.java:15518)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.Choreographer.doFrame(Choreographer.java:532)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.os.Handler.handleCallback(Handler.java:725)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.os.Looper.loop(Looper.java:137)
04-03 07:23:37.248: E/AndroidRuntime(933): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-03 07:23:37.248: E/AndroidRuntime(933): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 07:23:37.248: E/AndroidRuntime(933): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 07:23:37.248: E/AndroidRuntime(933): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-03 07:23:37.248: E/AndroidRuntime(933): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-03 07:23:37.248: E/AndroidRuntime(933): at dalvik.system.NativeStart.main(Native Method)
You are not following the Adapter customization properly. Check this . Your getView should be like the given code snippet. Can also check this

App stops when i want to open another class from a clickable listview

I am trying to make a listview and when i click to an item i want to opwn another class. The second class is actually for opening a file from raw folder.
my class is
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class Cod_rutier extends MainActivity2A {
private ListView lv1;
private String lv_arr[]={"CAP.1: Dispozitii generale",
"CAP.2: Vehiculele",
"CAP.3: Conducatorii de vehicule",
"CAP.4: Semnalizarea rutiera",
"CAP.5: Reguli de circulatie",
"CAP.6: Infractiuni si pedepse",
"CAP.7: Raspunderea contraventionala",
"CAP.8: Cai de atac impotriva procesului-verbal de constatare a contraventiei",
"CAP.9: Atributii ale unor ministere si ale altor autoritati ale administratiei publice",
"CAP.10: Dispozitii finale"};
/** Called when the activity is first created. */
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.legislatie);
lv1=(ListView)findViewById(R.id.listView1);
// By using setAdpater method in listview we an add string array in list.
lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
lv1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
final TextView mTextView = (TextView)view;
switch (position) {
case 0:
Intent newActivity0 = new Intent(Cod_rutier.this, Legislatie1.class);
startActivity(newActivity0);
break;
case 1:
Intent newActivity1 = new Intent(Cod_rutier.this, Legislatie2.class);
startActivity(newActivity1);
break;
case 2 :
Intent newActivity2 = new Intent(Cod_rutier.this, Legislatie3.class);
startActivity(newActivity2);
break;
case 3:
Intent newActivity3 = new Intent(Cod_rutier.this, Legislatie4.class);
startActivity(newActivity3);
break;
default:
}
}
});
}}
i put it into the manifest file but when i run it the app stops. This is my logcat
03-16 18:58:35.373: E/AndroidRuntime(828): FATAL EXCEPTION: main
03-16 18:58:35.373: E/AndroidRuntime(828): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vreaucarnet/com.example.vreaucarnet.Cod_rutier}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.os.Handler.dispatchMessage(Handler.java:99)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.os.Looper.loop(Looper.java:123)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-16 18:58:35.373: E/AndroidRuntime(828): at java.lang.reflect.Method.invokeNative(Native Method)
03-16 18:58:35.373: E/AndroidRuntime(828): at java.lang.reflect.Method.invoke(Method.java:521)
03-16 18:58:35.373: E/AndroidRuntime(828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-16 18:58:35.373: E/AndroidRuntime(828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-16 18:58:35.373: E/AndroidRuntime(828): at dalvik.system.NativeStart.main(Native Method)
03-16 18:58:35.373: E/AndroidRuntime(828): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-16 18:58:35.373: E/AndroidRuntime(828): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:172)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.Activity.requestWindowFeature(Activity.java:2719)
03-16 18:58:35.373: E/AndroidRuntime(828): at com.example.vreaucarnet.Cod_rutier.onCreate(Cod_rutier.java:33)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-16 18:58:35.373: E/AndroidRuntime(828): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-16 18:58:35.373: E/AndroidRuntime(828): ... 11 more
Can someone tell my where is my mistake?
Requesting any requestWindowFeature calls are done before super.onCreate calls in your activity
i.e
requestWindowFeature(Window.FEATURE_NO_TITLE); this should be called before super.onCreate()
change like
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
It is here:
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

Adding Model Class to Generic List throws error

I'm new to Android development and cant work out the issue here. I create a blank class called video with two properties name and url:
public class Video {
public String _name;
public String _Url;
public Video(String name, String Url)
{
_name = name;
_Url = Url;
}
public String getName()
{
return _name;
}
public String getUrl()
{
return _Url;
}
}
I then have a generic list for adding videos to in an activity calls VideosListActivity, the error is being thrown when i add the video to the list:
public List<Video> ListResult;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Update view
setContentView(R.layout.videos);
setTitle("VIDEOS");
//--videos created here
Video NewVideo = new Video("video one","http://www.youtube.com/watch?v=cxLG2wtE7TM");
ListResult.add(NewVideo);
Log.v("VideoList", "Opened list");
this error is what is thrown:
02-06 13:10:05.660: E/AndroidRuntime(23432): FATAL EXCEPTION: main
02-06 13:10:05.660: E/AndroidRuntime(23432): java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.co.mosquitodigital.panic/uk.co.mosquitodigital.panic.VideoListActivity}: java.lang.NullPointerException
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2260)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread.access$600(ActivityThread.java:139)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.os.Looper.loop(Looper.java:156)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread.main(ActivityThread.java:5045)
02-06 13:10:05.660: E/AndroidRuntime(23432): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 13:10:05.660: E/AndroidRuntime(23432): at java.lang.reflect.Method.invoke(Method.java:511)
02-06 13:10:05.660: E/AndroidRuntime(23432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-06 13:10:05.660: E/AndroidRuntime(23432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-06 13:10:05.660: E/AndroidRuntime(23432): at dalvik.system.NativeStart.main(Native Method)
02-06 13:10:05.660: E/AndroidRuntime(23432): Caused by: java.lang.NullPointerException
02-06 13:10:05.660: E/AndroidRuntime(23432): at uk.co.mosquitodigital.panic.VideoListActivity.onCreate(VideoListActivity.java:31)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.Activity.performCreate(Activity.java:4543)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
02-06 13:10:05.660: E/AndroidRuntime(23432): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2181)
02-06 13:10:05.660: E/AndroidRuntime(23432): ... 11 more
you will need to initialize ListResult List before adding elements to it as :
public List<Video> ListResult;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Update view
setContentView(R.layout.videos);
ListResult= new ArrayList<Video>(); //<< initialize List here

Keep getting Force close when I test my app

I'm build a app that consist of user login and registration but every time I test it on the emulator I receive a force close. Below are the errors I'm receiving in the log cat:
08-14 14:06:28.853: D/dalvikvm(828): GC_FOR_ALLOC freed 108K, 3% free 8262K/8455K, paused 89ms, total 92ms
08-14 14:06:29.273: I/Choreographer(828): Skipped 72 frames! The application may be doing too much work on its main thread.
08-14 14:06:29.373: D/gralloc_goldfish(828): Emulator without GPU emulation detected.
08-14 14:06:29.373: D/dalvikvm(828): GC_CONCURRENT freed 5K, 3% free 8660K/8839K, paused 110ms+28ms, total 365ms
08-14 14:06:29.902: I/Choreographer(828): Skipped 85 frames! The application may be doing too much work on its main thread.
08-14 14:06:32.533: D/dalvikvm(828): GC_CONCURRENT freed 32K, 3% free 9027K/9223K, paused 81ms+111ms, total 343ms
08-14 14:06:32.813: I/Choreographer(828): Skipped 71 frames! The application may be doing too much work on its main thread.
08-14 14:06:33.303: I/Choreographer(828): Skipped 38 frames! The application may be doing too much work on its main thread.
08-14 14:06:39.854: D/InputEventConsistencyVerifier(828): KeyEvent: ACTION_UP but key was not down.
08-14 14:06:39.854: D/InputEventConsistencyVerifier(828): in android.widget.EditText#412b2f68
08-14 14:06:39.854: D/InputEventConsistencyVerifier(828): 0: sent at 1614282000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_M, scanCode=50, metaState=0, flags=0x8, repeatCount=0, eventTime=1614282, downTime=1614282, deviceId=0, source=0x301 }
08-14 14:06:39.874: D/InputEventConsistencyVerifier(828): KeyEvent: ACTION_UP but key was not down.
08-14 14:06:39.874: D/InputEventConsistencyVerifier(828): in android.widget.EditText#412b2f68
08-14 14:06:39.874: D/InputEventConsistencyVerifier(828): 0: sent at 1614392000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=1614392, downTime=1614282, deviceId=0, source=0x301 }
08-14 14:06:39.874: D/InputEventConsistencyVerifier(828): -- recent events --
08-14 14:06:39.874: D/InputEventConsistencyVerifier(828): 1: sent at 1614282000000, (unhandled) KeyEvent { action=ACTION_UP, keyCode=KEYCODE_M, scanCode=50, metaState=0, flags=0x80000008, repeatCount=0, eventTime=1614282, downTime=1614282, deviceId=0, source=0x301 }
08-14 14:07:02.362: D/AndroidRuntime(828): Shutting down VM
08-14 14:07:02.362: W/dalvikvm(828): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
**08-14 14:07:02.472: E/AndroidRuntime(828): FATAL EXCEPTION: main
08-14 14:07:02.472: E/AndroidRuntime(828): android.os.NetworkOnMainThreadException
08-14 14:07:02.472: E/AndroidRuntime(828): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-14 14:07:02.472: E/AndroidRuntime(828): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-14 14:07:02.472: E/AndroidRuntime(828): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
08-14 14:07:02.472: E/AndroidRuntime(828): at libcore.io.IoBridge.connect(IoBridge.java:112)
08-14 14:07:02.472: E/AndroidRuntime(828): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
08-14 14:07:02.472: E/AndroidRuntime(828): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
08-14 14:07:02.472: E/AndroidRuntime(828): at java.net.Socket.connect(Socket.java:842)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-14 14:07:02.472: E/AndroidRuntime(828): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-14 14:07:02.472: E/AndroidRuntime(828): at library.JSONParser.getJSONFromUrl(JSONParser.java:41)
08-14 14:07:02.472: E/AndroidRuntime(828): at library.UserFunctions.loginUser(UserFunctions.java:40)
08-14 14:07:02.472: E/AndroidRuntime(828): at com.thryfting.www.LoginActivity.onClick(LoginActivity.java:66)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.view.View.performClick(View.java:4084)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.view.View$PerformClick.run(View.java:16966)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.os.Handler.handleCallback(Handler.java:615)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.os.Handler.dispatchMessage(Handler.java:92)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.os.Looper.loop(Looper.java:137)
08-14 14:07:02.472: E/AndroidRuntime(828): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-14 14:07:02.472: E/AndroidRuntime(828): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 14:07:02.472: E/AndroidRuntime(828): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 14:07:02.472: E/AndroidRuntime(828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-14 14:07:02.472: E/AndroidRuntime(828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-14 14:07:02.472: E/AndroidRuntime(828): at dalvik.system.NativeStart.main(Native Method)**
Updated code for register activity:
package com.thryfting.www;
import org.json.JSONException;
import org.json.JSONObject;
import library.DatabaseHandler;
import library.UserFunctions;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockActivity;
public class RegisterActivity extends SherlockActivity implements OnClickListener{
Button btnRegister;
EditText inputFullName;
EditText inputEmail;
EditText inputPassword;
TextView registerErrorMsg;
TextView loginScreen;
//JSON Response node names
private static String KEY_SUCCESS = "success";
private static String KEY_ERROR = "error";
private static String KEY_ERROR_MSG = "error_msg";
private static String KEY_UID = "uid";
private static String KEY_NAME = "name";
private static String KEY_EMAIL = "email";
private static String KEY_CREATED_AT = "created_at";
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
loginScreen = (TextView) findViewById(R.id.link_to_login);
inputEmail = (EditText) findViewById(R.id.etemailSignup);
inputPassword = (EditText) findViewById(R.id.etPasswordSignup);
inputFullName = (EditText) findViewById(R.id.etFullnameSignup);
btnRegister = (Button) findViewById(R.id.btnRegister);
registerErrorMsg = (TextView) findViewById(R.id.register_error);
loginScreen.setOnClickListener(this);
btnRegister.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.btnRegister:
new register().execute(KEY_SUCCESS);
break;
case R.id.link_to_login:
Intent i = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(i);
//Close Registration View
finish();
break;
}
}
public class register extends AsyncTask<String, Integer, String>{
#Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
String name = inputFullName.getText().toString();
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
UserFunctions userFunction = new UserFunctions();
JSONObject json = userFunction.registerUser(name, email, password);
try{
if(json.getString(KEY_SUCCESS) != null){
registerErrorMsg.setText("");
String res = json.getString(KEY_SUCCESS);
if(Integer.parseInt(res) == 1){
//user successfully registered
// Store user details in SQLite Database
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
JSONObject json_user = json.getJSONObject("user");
//Clear all previous data in database
userFunction.logoutUser(getApplicationContext());
db.addUser(json_user.getString(KEY_NAME), json_user.getString(KEY_EMAIL), json.getString(KEY_UID), json_user.getString(KEY_CREATED_AT));
}else{
//Error in registration
registerErrorMsg.setText("Error occured in registration");
}
}
} catch(JSONException e){
e.printStackTrace();
} finally{
//Launch Dashboard
Intent dashboard = new Intent (getApplicationContext(), Timeline.class);
//Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//Close registration screen
finish();
}
return null;
}
}
}
New error messages below:
08-15 14:53:32.940: W/dalvikvm(865): threadid=11: thread exiting with uncaught exception (group=0x40a13300)
08-15 14:53:33.060: E/AndroidRuntime(865): FATAL EXCEPTION: AsyncTask #1
08-15 14:53:33.060: E/AndroidRuntime(865): java.lang.RuntimeException: An error occured while executing doInBackground()
08-15 14:53:33.060: E/AndroidRuntime(865): at android.os.AsyncTask$3.done(AsyncTask.java:299)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-15 14:53:33.060: E/AndroidRuntime(865): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.lang.Thread.run(Thread.java:856)
08-15 14:53:33.060: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=register
08-15 14:53:33.060: E/AndroidRuntime(865): at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
08-15 14:53:33.060: E/AndroidRuntime(865): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
08-15 14:53:33.060: E/AndroidRuntime(865): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-15 14:53:33.060: E/AndroidRuntime(865): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-15 14:53:33.060: E/AndroidRuntime(865): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-15 14:53:33.060: E/AndroidRuntime(865): at library.JSONParser.getJSONFromUrl(JSONParser.java:41)
08-15 14:53:33.060: E/AndroidRuntime(865): at library.UserFunctions.registerUser(UserFunctions.java:63)
08-15 14:53:33.060: E/AndroidRuntime(865): at com.thryfting.www.RegisterActivity$register.doInBackground(RegisterActivity.java:89)
08-15 14:53:33.060: E/AndroidRuntime(865): at com.thryfting.www.RegisterActivity$register.doInBackground(RegisterActivity.java:1)
08-15 14:53:33.060: E/AndroidRuntime(865): at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-15 14:53:33.060: E/AndroidRuntime(865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-15 14:53:33.060: E/AndroidRuntime(865): ... 5 more
08-15 14:53:34.812: I/Choreographer(865): Skipped 93 frames! The application may be doing too much work on its main thread.
08-15 14:53:36.512: I/Process(865): Sending signal. PID: 865 SIG: 9
public JSONObject registerUser(String name, String email, String password){
//building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", register_tag));
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
//Getting JSON object
JSONObject json = jsonParser.getJSONFromUrl(register_tag, params);
//return json
return json;
}
Your getting a StrictMode violation. This means that you are doing something blocking on the UI Thread. Hence the reason for
android.os.NetworkOnMainThreadException
From the rest of your LOG it appears your performing a web request.
Make sure that HTTP request is wrapped in an AsyncTask (or something similar)
It seems like you are trying to do your login and registration on the main Thread. First of all this is bad practice, and it can't be done on recent API levels.
All you need to do is make your network connections in a separate thread, be it an AsyncTask or just a plain old Thread()
as an example :
use this
public void login()
{
new Thread(new Runnable() {
#Override
public void run() {
//your network connection goes here
}
}).start();
}
instead of :
public void login()
{
//your network connection goes here
}
Try to check the same in a mobile with internet connectivity.
The logcat also displays that the emulator doesnt has a GPS connectivity.

Categories