-1

I am new at this (I mean brand spanking new). No this is not a homework assignment.

My app continues to crash on my phone and on the AVD. I am not sure what is going on. I followed this tutorial: https://www.youtube.com/watch?v=E8BVJWcEqHE .Can I get a little help please? This is a simple notepad style app which I am aiming for a 4.2 platform. I would post the LOGCAT but it is at 10,000 entries currently and is going to be more of an annoyance for you than anything else.

Thank you

MainActivity:

package com.example.shopez;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;


import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.os.Build;

public class MainActivity extends Activity implements OnClickListener{

    TextView mtextOutput;
    EditText mtextInput;
    final static String FILENAME="notes.txt";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupWidgets();

        loadTextFromFile();
        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }

    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;
    }
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }


    private void loadTextFromFile() {
        File f = new File(getFilesDir(),FILENAME);
        try {
            BufferedReader br = new BufferedReader(new FileReader(f));

            String line;
            while((line=br.readLine())!=null){
                mtextOutput.setText(line+"\n"+mtextOutput.getText());
                }
            br.close();
        } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

        } catch (IOException e) {
        // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


    private void setupWidgets() {
        Button save = (Button)findViewById(R.id.save);
        save.setOnClickListener(this);
        mtextOutput = (TextView)findViewById(R.id.textView);
        mtextInput = (EditText)findViewById(R.id.textInput);
        mtextOutput.setMovementMethod(new ScrollingMovementMethod());


    }


    @Override



    public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v.getId()==R.id.save){
            String text = mtextInput.getText().toString();
            mtextInput.setText("");

            mtextOutput.setText(text+"\n"+mtextOutput.getText().toString());
            try {
                FileOutputStream fo = openFileOutput(FILENAME, Context.MODE_APPEND);
                fo.write(text.getBytes());
                fo.write("\n".getBytes());


            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }


        }
    }

}

fragment_main.xml

<RelativeLayout 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="com.example.shopez.MainActivity$PlaceholderFragment" >

    <Button
        android:id="@+id/save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="20dp"
        android:text="Button" />

    <EditText
        android:id="@+id/textInput"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/save"
        android:layout_alignParentLeft="true"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textInput"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textInput"
        android:layout_marginTop="19dp"
        android:text="TextView" />

</RelativeLayout>

MAINIFEST

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

    <uses-sdk
        android:minSdkVersion="17"
        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.example.shopez.MainActivity"
        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>

LOGCAT ERROR - I grabbed a chunk of errors I hope this is somewhat of a help

   04-30 18:15:57.177: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:15:59.489: E/jdwp(32276): Failed sending reply to debugger: Bad file number
04-30 18:16:00.110: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:4.300000 hotplug_avg_load_dw: 56
04-30 18:16:00.110: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:147.000000
04-30 18:16:00.160: E/MP-Decision(1700): num online cores: 2 reqd : 3 available : 4 rq_depth:2.900000 hotplug_avg_load_dw: 77
04-30 18:16:00.160: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:00.160: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:190.000000
04-30 18:16:00.350: E/SELinux(32305): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-30 18:16:00.490: E/AndroidRuntime(32305): FATAL EXCEPTION: main
04-30 18:16:00.490: E/AndroidRuntime(32305): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shopez/com.example.shopez.MainActivity}: java.lang.NullPointerException
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread.access$700(ActivityThread.java:152)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.os.Looper.loop(Looper.java:137)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread.main(ActivityThread.java:5328)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at java.lang.reflect.Method.invokeNative(Native Method)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at java.lang.reflect.Method.invoke(Method.java:511)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at dalvik.system.NativeStart.main(Native Method)
04-30 18:16:00.490: E/AndroidRuntime(32305): Caused by: java.lang.NullPointerException
04-30 18:16:00.490: E/AndroidRuntime(32305):    at com.example.shopez.MainActivity.setupWidgets(MainActivity.java:103)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at com.example.shopez.MainActivity.onCreate(MainActivity.java:39)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.Activity.performCreate(Activity.java:5250)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
04-30 18:16:00.490: E/AndroidRuntime(32305):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
04-30 18:16:00.490: E/AndroidRuntime(32305):    ... 11 more
04-30 18:16:00.911: E/MP-Decision(1700): num online cores: 3 reqd : 1 available : 4 rq_depth:0.500000 hotplug_avg_load_dw: 14
04-30 18:16:00.911: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:243.000000
04-30 18:16:00.911: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:243.000000
04-30 18:16:01.171: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:01.451: E/LightSensor(775): Light old sensor_state 0, new sensor_state : 128 en : 1
04-30 18:16:01.481: E/Sensors(775): Acc old sensor_state 128, new sensor_state : 129 en : 1
04-30 18:16:02.012: E/ANDR-PERF-MPCTL(775): MPCTL client send 3
04-30 18:16:02.142: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:3.700000 hotplug_avg_load_dw: 38
04-30 18:16:02.142: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:674.000000
04-30 18:16:02.342: E/GestureService(1577): updateFlags started
04-30 18:16:02.342: E/GestureService(1577): bVertical = false
04-30 18:16:02.342: E/GestureService(1577): bHorizontal = false
04-30 18:16:02.422: E/0409(3501): call setFingerHoveredInAppWidge in remoteview. enabled:false
04-30 18:16:02.442: E/MP-Decision(1700): num online cores: 2 reqd : 3 available : 4 rq_depth:3.700000 hotplug_avg_load_dw: 78
04-30 18:16:02.442: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:02.442: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:98.000000
04-30 18:16:02.442: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:02.492: E/MP-Decision(1700): num online cores: 3 reqd : 4 available : 4 rq_depth:5.300000 hotplug_avg_load_dw: 201
04-30 18:16:02.492: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:02.492: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
04-30 18:16:02.492: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:96.000000
04-30 18:16:02.522: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:02.602: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:02.893: E/MP-Decision(1700): num online cores: 4 reqd : 2 available : 4 rq_depth:1.200000 hotplug_avg_load_dw: 60
04-30 18:16:02.893: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
04-30 18:16:02.893: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
04-30 18:16:02.953: E/MotionRecognitionService(775):   mReceiver.onReceive : ACTION_USER_PRESENT  :: UNLOCK SCREEN
04-30 18:16:03.043: E/MP-Decision(1700): num online cores: 2 reqd : 4 available : 4 rq_depth:5.500000 hotplug_avg_load_dw: 106
04-30 18:16:03.043: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:03.043: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:98.000000
04-30 18:16:03.043: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:98.000000
04-30 18:16:03.043: E/EnterpriseContainerManager(775): ContainerPolicy Service is not yet ready!!!
04-30 18:16:03.133: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:03.393: E/MP-Decision(1700): num online cores: 4 reqd : 2 available : 4 rq_depth:0.200000 hotplug_avg_load_dw: 56
04-30 18:16:03.393: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
04-30 18:16:03.393: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
04-30 18:16:03.493: E/MP-Decision(1700): num online cores: 2 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 18
04-30 18:16:03.493: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:138.000000
04-30 18:16:03.693: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:5.500000 hotplug_avg_load_dw: 52
04-30 18:16:03.693: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:183.000000
04-30 18:16:03.743: E/MP-Decision(1700): num online cores: 2 reqd : 3 available : 4 rq_depth:4.500000 hotplug_avg_load_dw: 101
04-30 18:16:03.743: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:03.743: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:230.000000
04-30 18:16:04.294: E/MP-Decision(1700): num online cores: 3 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 16
04-30 18:16:04.294: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
04-30 18:16:04.294: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:245.000000
04-30 18:16:04.494: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:2.500000 hotplug_avg_load_dw: 56
04-30 18:16:04.494: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:147.000000
04-30 18:16:04.544: E/AllShare(ASF_DMC)(21602): [CP_DISCOVERY] ParseURI: 490: No IP value
04-30 18:16:05.045: E/MP-Decision(1700): num online cores: 2 reqd : 1 available : 4 rq_depth:1.000000 hotplug_avg_load_dw: 24
04-30 18:16:05.045: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:196.000000
04-30 18:16:05.165: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:05.235: E/MP-Decision(1700): num online cores: 1 reqd : 3 available : 4 rq_depth:4.100000 hotplug_avg_load_dw: 62
04-30 18:16:05.235: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:186.000000
04-30 18:16:05.235: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:98.000000
04-30 18:16:05.525: E/NotificationService(775): Suppressing notification from package com.weather.Weather by user request.
04-30 18:16:05.535: E/NotificationService(775): Suppressing notification from package com.weather.Weather by user request.
04-30 18:16:05.785: E/MP-Decision(1700): num online cores: 3 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 10
04-30 18:16:05.785: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
04-30 18:16:05.785: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:245.000000
04-30 18:16:07.067: E/Watchdog(775): !@Sync 440
04-30 18:16:08.168: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:3.500000 hotplug_avg_load_dw: 24
04-30 18:16:08.168: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:146.000000
04-30 18:16:08.208: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:08.218: E/MP-Decision(1700): num online cores: 2 reqd : 4 available : 4 rq_depth:3.900000 hotplug_avg_load_dw: 122
04-30 18:16:08.218: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:08.218: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:191.000000
04-30 18:16:08.218: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:191.000000
04-30 18:16:08.468: E/MP-Decision(1700): num online cores: 4 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 29
04-30 18:16:08.468: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:240.000000
04-30 18:16:08.468: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:240.000000
04-30 18:16:08.468: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:240.000000
04-30 18:16:09.179: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:11.941: E/AllShare(ASF_DMC)(21602): [CP_DISCOVERY] ParseURI: 490: No IP value
04-30 18:16:13.183: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:17.267: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:21.261: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:25.274: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:28.007: E/SELinux(32445): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-30 18:16:28.197: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:1.100000 hotplug_avg_load_dw: 64
04-30 18:16:28.197: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:28.448: E/MP-Decision(1700): num online cores: 2 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 25
04-30 18:16:28.448: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:237.000000
04-30 18:16:29.268: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:32.952: E/LightSensor(775): Light old sensor_state 129, new sensor_state : 1 en : 0
04-30 18:16:32.952: E/Sensors(775): Acc old sensor_state 1, new sensor_state : 0 en : 0
04-30 18:16:33.022: E/ANDR-PERF-MPCTL(775): MPCTL client send 2
04-30 18:16:33.202: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:12.900000 hotplug_avg_load_dw: 41
04-30 18:16:33.202: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:144.000000
04-30 18:16:33.212: E/LightSensor(775): Light old sensor_state 0, new sensor_state : 128 en : 1
04-30 18:16:33.242: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.242: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.242: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.242: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.252: E/MP-Decision(1700): num online cores: 2 reqd : 4 available : 4 rq_depth:11.300000 hotplug_avg_load_dw: 142
04-30 18:16:33.252: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:33.252: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:193.000000
04-30 18:16:33.262: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:193.000000
04-30 18:16:33.272: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:33.282: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.282: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.282: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.282: E/LSO(775): LSO Service is not yet ready!!!
04-30 18:16:33.392: E/InputEventModelImpl(2442): onStartInput event aborted: com.touchtype.keyboard.inputeventmodel.ExtractedTextUnavailableException: could not obtain extracted text (class com.touchtype.keyboard.inputeventmodel.ExtractedTextUnavailableException)
04-30 18:16:33.512: E/LightSensor(775): Light old sensor_state 128, new sensor_state : 0 en : 0
04-30 18:16:33.603: E/AllShare(ASF_DMC)(21602): [NETWORK_LAYER] receive_handler: 224: [Multicast Server::receive_handler] Canceled [Operation Canceled]
04-30 18:16:33.603: E/AllShare(ASF_DMC)(21602): [NETWORK_LAYER] read_handler: 215: [UDPServer::read_handler] Canceled [Operation Canceled]
04-30 18:16:33.623: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:33.703: E/MP-Decision(1700): num online cores: 4 reqd : 3 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 87
04-30 18:16:33.703: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
04-30 18:16:33.753: E/MP-Decision(1700): num online cores: 3 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 8
04-30 18:16:33.753: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:95.000000
04-30 18:16:33.753: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:95.000000
04-30 18:16:34.694: E/LightSensor(775): Light old sensor_state 0, new sensor_state : 128 en : 1
04-30 18:16:34.764: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:34.834: E/Sensors(775): Acc old sensor_state 128, new sensor_state : 129 en : 1
04-30 18:16:34.954: E/LightSensor(775): Light old sensor_state 129, new sensor_state : 1 en : 0
04-30 18:16:35.104: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:35.174: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:4.000000 hotplug_avg_load_dw: 29
04-30 18:16:35.174: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:194.000000
04-30 18:16:35.534: E/MP-Decision(1700): num online cores: 2 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 12
04-30 18:16:35.534: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:305.000000
04-30 18:16:36.535: E/LightSensor(775): Light old sensor_state 1, new sensor_state : 129 en : 1
04-30 18:16:37.046: E/ANDR-PERF-MPCTL(775): MPCTL client send 3
04-30 18:16:37.056: E/Watchdog(775): !@Sync 441
04-30 18:16:37.116: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:18.100000 hotplug_avg_load_dw: 34
04-30 18:16:37.116: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:578.000000
04-30 18:16:37.166: E/MP-Decision(1700): num online cores: 2 reqd : 4 available : 4 rq_depth:4.000000 hotplug_avg_load_dw: 142
04-30 18:16:37.166: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:37.166: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:625.000000
04-30 18:16:37.166: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:625.000000
04-30 18:16:37.266: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:37.326: E/GestureService(1577): updateFlags started
04-30 18:16:37.326: E/GestureService(1577): bVertical = false
04-30 18:16:37.326: E/GestureService(1577): bHorizontal = false
04-30 18:16:37.376: E/0409(3501): call setFingerHoveredInAppWidge in remoteview. enabled:false
04-30 18:16:37.396: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:37.717: E/MP-Decision(1700): num online cores: 4 reqd : 3 available : 4 rq_depth:2.200000 hotplug_avg_load_dw: 86
04-30 18:16:37.717: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
04-30 18:16:37.867: E/MotionRecognitionService(775):   mReceiver.onReceive : ACTION_USER_PRESENT  :: UNLOCK SCREEN
04-30 18:16:37.877: E/SELinux(32538): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-30 18:16:37.907: E/EnterpriseContainerManager(775): ContainerPolicy Service is not yet ready!!!
04-30 18:16:37.967: E/MP-Decision(1700): num online cores: 3 reqd : 4 available : 4 rq_depth:5.700000 hotplug_avg_load_dw: 116
04-30 18:16:37.967: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
04-30 18:16:37.967: E/MP-Decision(1700): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
04-30 18:16:37.967: E/MP-Decision(1700): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:96.000000
04-30 18:16:38.077: E/SELinux(32558): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-30 18:16:38.267: E/MP-Decision(1700): num online cores: 4 reqd : 3 available : 4 rq_depth:1.200000 hotplug_avg_load_dw: 88
04-30 18:16:38.267: E/MP-Decision(1700): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000
04-30 18:16:38.567: E/MP-Decision(1700): num online cores: 3 reqd : 1 available : 4 rq_depth:0.100000 hotplug_avg_load_dw: 28
04-30 18:16:38.567: E/MP-Decision(1700): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:195.000000
04-30 18:16:38.567: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:195.000000
04-30 18:16:38.748: E/WifiHW(775): ##################### set firmware type 0 #####################
04-30 18:16:41.270: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:45.274: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:46.976: E/MP-Decision(1700): num online cores: 1 reqd : 2 available : 4 rq_depth:2.100000 hotplug_avg_load_dw: 31
04-30 18:16:46.976: E/MP-Decision(1700): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:194.000000
04-30 18:16:47.326: E/MP-Decision(1700): num online cores: 2 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 27
04-30 18:16:47.326: E/MP-Decision(1700): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:292.000000
04-30 18:16:49.288: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:53.302: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
04-30 18:16:57.306: E/QcrilMsgTunnelSocket(30170): IOExceptionjava.io.IOException: No such file or directoryReason: No such file or directory
Paul
  • 521
  • 1
  • 5
  • 14
  • `adb logcat -c` to clear your logcat entries file. I imagine all 10000 lines may not be due to your application alone. Try posting last 20 lines in any case. – PCoder Apr 30 '14 at 21:49
  • Find the *error* in your logcat (red lines) and only post those. Chances are, you'll see what the problem is once you find it. – 323go Apr 30 '14 at 21:55
  • Updated with logcat errors – Paul Apr 30 '14 at 22:18
  • Why would you do that `save.setOnClickListener(this);` ? remove it, and add in you XML file on your button code `android:onClick="saveAction"` and then add a method in your activity `public void saveAction (View view){ //Do whatever you want when the button is clicked } ` –  Apr 30 '14 at 22:36

2 Answers2

0

Read your log, the error is on the method setupWidgets. If you want to work with fragments, the UI is created on fragment class PlaceholderFragment. Move all methods from activities into fragment class. See the code below.

package com.example.shopez;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    final static String FILENAME = "notes.txt";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    }

    @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;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment implements
            OnClickListener {

        TextView mtextOutput;
        EditText mtextInput;

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);
            Button save = (Button) rootView.findViewById(R.id.save);
            save.setOnClickListener(this);

            mtextOutput = (TextView) rootView.findViewById(R.id.textView);
            mtextInput = (EditText) rootView.findViewById(R.id.textInput);
            mtextOutput.setMovementMethod(new ScrollingMovementMethod());

            return rootView;
        }

        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            loadTextFromFile();
        }

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (v.getId() == R.id.save) {
                String text = mtextInput.getText().toString();
                mtextInput.setText("");

                mtextOutput.setText(text + "\n"
                        + mtextOutput.getText().toString());
                try {
                    FileOutputStream fo = getActivity().openFileOutput(
                            FILENAME, Context.MODE_APPEND);
                    fo.write(text.getBytes());
                    fo.write("\n".getBytes());

                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        }

        private void loadTextFromFile() {
            File f = new File(getActivity().getFilesDir(), FILENAME);
            try {
                BufferedReader br = new BufferedReader(new FileReader(f));

                String line;
                while ((line = br.readLine()) != null) {
                    mtextOutput.setText(line + "\n" + mtextOutput.getText());
                }
                br.close();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}

The applications doesn't works because missing file, but doesn't crashed. I hope you serve.

Cesardl
  • 1,831
  • 1
  • 14
  • 18
0

In my case, the Access Rules Defined has been with the value "Forbidden". I removed it and made to None.

The error is gone and my app is working fine.

My logcat messages are fr your reference:

11-05 07:48:32.330: E/MP-Decision(1774): num online cores: 4 reqd : 3 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 35 11-05 07:48:32.330: E/MP-Decision(1774): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:245.000000 11-05 07:48:32.380: E/MP-Decision(1774): num online cores: 3 reqd : 1 available : 4 rq_depth:0.000000 hotplug_avg_load_dw: 8 11-05 07:48:32.380: E/MP-Decision(1774): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:242.000000 11-05 07:48:32.380: E/MP-Decision(1774): DOWN cpu:1 core_idx:1 Ns:1.100000 Ts:190 total_time_down:242.000000

my console error messages for your reference:

[2014-11-05 20:22:11 - PlacePickerSample] Android Launch! [2014-11-05 20:22:11 - PlacePickerSample] adb is running normally. [2014-11-05 20:22:11 - PlacePickerSample] Performing com.facebook.samples.placepicker.PlacePickerSampleActivity activity launch [2014-11-05 20:22:11 - PlacePickerSample] Automatic Target Mode: Unable to detect device compatibility. Please select a target device. [2014-11-05 20:22:15 - PlacePickerSample] Uploading PlacePickerSample.apk onto device '1f95e524' [2014-11-05 20:22:15 - PlacePickerSample] Installing PlacePickerSample.apk... [2014-11-05 20:22:17 - PlacePickerSample] Installation failed due to invalid APK file! [2014-11-05 20:22:17 - PlacePickerSample] Please check logcat output for more details. [2014-11-05 20:22:17 - PlacePickerSample] Launch canceled!