不幸的是<的applicationName>已经停止 [英] unfortunately <applicationName> has stopped

查看:146
本文介绍了不幸的是<的applicationName>已经停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我不知道规则是什么在这里对双重职位,anywho我没有得到后续支持,对我的其他问题.. anywho我的问题是说,我的继承人的logcat

  05-28 19:45:03.464:I / ActivityManager(274):启动PROC xela.kasea.flyffresell的活动xela.kasea.flyffresell /。主要:PID = 793 UID = 10046导报= {50046,1028}
05-28 19:45:03.474:D / dalvikvm(793):不晚启用CheckJNI(已上)
05-28 19:45:04.154:I / ARMAssembler(36):产生scanline__00000077:03010104_00008001_00000000 [89 IPP(110英寸),在[0x41548840:0x415489f8在564149 NS
05-28 19:45:04.294:D / dalvikvm(793):GC_FOR_ALLOC释放81K,6%免费2642K / 2784K,暂停26ms,共27ms
05-28 19:45:04.294:I / dalvikvm堆(793):增长堆(破片的情况下),以3.318MB为714016字节分配
05-28 19:45:04.334:D / dalvikvm(793):GC_FOR_ALLOC释放2K,5%的游离3337K / 3484K,暂停34ms,共34ms
05-28 19:45:04.414:I /与Tag2(793):这是我的错误味精
05-28 19:45:04.414:D / AndroidRuntime(793):关闭虚拟机
05-28 19:45:04.414:W / dalvikvm(793):主题ID = 1:螺纹退出与未捕获的异常(组= 0x41465700)
05-28 19:45:04.425:E / AndroidRuntime(793):致命异常:主要
05-28 19:45:04.425:E / AndroidRuntime(793):java.lang.RuntimeException的:无法启动的活动ComponentInfo {xela.kasea.flyffresell / xela.kasea.flyffresell.Main}:显示java.lang.NullPointerException
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread.access $ 600(ActivityThread.java:141)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1256)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.os.Handler.dispatchMessage(Handler.java:99)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.os.Looper.loop(Looper.java:137)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread.main(ActivityThread.java:5103)
05-28 19:45:04.425:E / AndroidRuntime(793):在java.lang.reflect.Method.invokeNative(本机方法)
05-28 19:45:04.425:E / AndroidRuntime(793):在java.lang.reflect.Method.invoke(Method.java:525)
05-28 19:45:04.425:E / AndroidRuntime(793):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:737)
05-28 19:45:04.425:E / AndroidRuntime(793):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-28 19:45:04.425:E / AndroidRuntime(793):在dalvik.system.NativeStart.main(本机方法)
05-28 19:45:04.425:E / AndroidRuntime(793):由:显示java.lang.NullPointerException
05-28 19:45:04.425:E / AndroidRuntime(793):在xela.kasea.flyffresell.Main.onCreate(Main.java:31)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.Activity.performCreate(Activity.java:5133)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-28 19:45:04.425:E / AndroidRuntime(793):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
05-28 19:45:04.425:E / AndroidRuntime(793):11 ...更多
05-28 19:45:04.433:W / ActivityManager(274):强制完成活动xela.kasea.flyffresell /。主要
05-28 19:45:04.743:I /窗口管理器(274):截图最大重试4令牌{41792b40 ActivityRecord {418a4ce0 U0 xela.kasea.flyffresell /。主要}} appWin =窗口{41943b50 U0开始xela.kasea.flyffresell } drawState = 4
05-28 19:45:04.743:W /窗口管理器(274):截图失败采取截图(400x800)到层21010
05-28 19:45:05.133:D / AlertService(580):开始updateAlertNotification
05-28 19:45:05.214:D / AlertService(580):没有解雇或预定警报
05-28 19:45:05.263:W / ActivityManager(274):活动暂停超时ActivityRecord {418a4ce0 U0 xela.kasea.flyffresell /。主要}
05-28 19:45:05.593:D / AlertService(580):安排一个报警与AlarmScheduler。 sEventReminderReceived:空
05-28 19:45:05.853:D / AlarmScheduler(580):没有发现在1周内起事件。
05-28 19:45:06.503:I /处理(793):发送信号。 PID:793 SIG:9
05-28 19:45:06.513:I / ActivityManager(274):过程xela.kasea.flyffresell(PID 793)已经死亡。
 

和我的继承人main.java。注:我只使用一个类

 包xela.kasea.flyffresell;


进口android.app.Activity;
进口android.os.Bundle;
进口android.util.Log;
进口android.view.View;
进口android.view.View.OnClickListener;
进口android.widget.Button;
进口android.widget.EditText;
进口android.widget.TextView;
进口android.widget.ToggleButton;

公共类主要活动扩展实现OnClickListener {

    的EditText PERIN,amountPrUnit,购买,出售;
    切换按钮懒惰;
    按键清晰,提交,RET;
    双ANS,subAnswer;
    TextView的pEarned,tAmount;

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.display);
        Log.i(与Tag2,这是我的错误味精);
        initalizer();
        lazy.setOnClickListener(本);
        clear.setOnClickListener(本);
        submit.setOnClickListener(本);
        ret.setOnClickListener(本);
        / *字符串A = perin.getText()的toString()。
        字符串B = amountPrUnit.getText()的toString()。
        。字符串C = buy.getText()的toString();
        串D = sell.getText()的toString()。 * /
    }

    私人无效initalizer(){
        // TODO自动生成方法存根
        PERIN =(EditText上)findViewById(R.id.etHowRich);
        amountPrUnit =(EditText上)findViewById(R.id.etAmountPrUnit);
        买=(EditText上)findViewById(R.id.etBuying);
        卖=(EditText上)findViewById(R.id.etSellingPrUnit);
        懒=(切换按钮)findViewById(R.id.tbBuying);
        明确=(按钮)findViewById(R.id.bClear);
        提交=(按钮)findViewById(R.id.bSubmit);
        RET =(按钮)findViewById(R.id.bReturn);
        pEarned =(TextView中)findViewById(R.id.tvEarned);
        tAmount =(TextView中)findViewById(R.id.tvAmount);
        / * INT一个=的Integer.parseInt(perin.getText()的toString());
        INT B =的Integer.parseInt(amountPrUnit.getText()的toString());
        INT C =的Integer.parseInt(buy.getText()的toString());
        INT D =的Integer.parseInt(sell.getText()的toString()); * /
    }

    @覆盖
    公共无效的onClick(视图v){
        // TODO自动生成方法存根
        INT一个=的Integer.parseInt(perin.getText()的toString());
        INT B =的Integer.parseInt(amountPrUnit.getText()的toString());
        INT C =的Integer.parseInt(buy.getText()的toString());
        INT D =的Integer.parseInt(sell.getText()的toString());
        开关(v.getId()){
        案例R.id.bClear:
            perin.setText();
            amountPrUnit.setText();
            buy.setText();
            sell.setText();
            lazy.setChecked(假);
            打破;
        案例R.id.bReturn:
            的setContentView(R.layout.display);
            打破;
        案例R.id.bSubmit:
            pEarned.setText(三* D-(α-(B * C)));
            tAmount.setText(C * D +(α-(α-(B * C))));
            的setContentView(R.layout.finish);
            打破;
        案例R.id.tbBuying:
            如果(lazy.isChecked()){
            buy.setText();
            双subAnswer = 0;
            INT ANS = 0;
            subAnswer = A / B;
            ANS =(INT)Math.floor(subAnswer);
            / *新的整数((int)的ANS)的ToString();
            Integer.toString(答案); * /
            buy.setText(ANS);;
            }
            打破;
        }
    }
}
 

这是什么程序是该做的,需要几个用户输入的号码,并做一些数学与他们。

如果你需要它,继承人的清单

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=xela.kasea.flyffresell
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =16
        机器人:targetSdkVersion =19/>

    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>
        <活动
            机器人:主名称=
            机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>

< /舱单>
 

解决方案

我觉得此评论的用户需要解释什么是基本主题的答案Java的:

  

如果我可能会问,什么NullPointerException异常?

指针意味着你正试图操纵对象变量没有分配给它的任何记忆。该 NullPointerException异常是告诉你的Java的道:喂,你是试图操纵变量(即设置一个监听器)是指向没有记忆的位置;没有对象实例化这个变量或已经是垃圾收集。您正在尝试去使用尚未尚未建成的建筑物的浴室。

该堆栈跟踪是不错的(你应该和他的朋友),并告诉我们,在我们的$ C C的异常$的这行被抛出:

  05-28 19:45:04.425:E / AndroidRuntime(793):由:显示java.lang.NullPointerException
05-28 19:45:04.425:E / AndroidRuntime(793):在xela.kasea.flyffresell.Main.onCreate(Main.java:31)
 

这意味着你需要去检查线路的code和找出哪些变量是。大多数现代IDE的引入有断点,让你看到在运行时变量的状态的选项。一旦你知道哪些变量是你可以更容易地找出原因。所以,你的情况,导致问题的行 Main.java 31行。从我们知道的意见,你说行是:

  ret.setOnClickListender(本);
 

这是留给我们的一个选择; RET 必须。然后,我们问自己:

  

会发生什么,在正常情况下,可以使RET是

1)变量没有被初始化;我们忘了初始化。不是我们的情况。

2)变量被garbaged收集。不是我们的情况。

3)遇到了一些问题,当我们试图初始化我们的变量。也许我们的情况。

在这种情况下,我们不会通过调用某些类的构造函数初始化变量,我们通过一个方法做到这一点(即 findViewById())。此方法需要一个 INT ,应该是 ID 查看我们要设置 RET 来,它要么返回查看的问题。所以,如果这一点正确思想,错误可能是,我们使用了错误的ID。

这答案是更多的表现出的思维方式,而不是一个实际的解决方案,因为实在是没有足够的信息来解决问题。

So i don't know what the rules are here about double posts, anywho i didn't get follow up support on my other question.. anywho my problem is stated, heres my logcat

05-28 19:45:03.464: I/ActivityManager(274): Start proc xela.kasea.flyffresell for activity xela.kasea.flyffresell/.Main: pid=793 uid=10046 gids={50046, 1028}
05-28 19:45:03.474: D/dalvikvm(793): Not late-enabling CheckJNI (already on)
05-28 19:45:04.154: I/ARMAssembler(36): generated scanline__00000077:03010104_00008001_00000000 [ 89 ipp] (110 ins) at [0x41548840:0x415489f8] in 564149 ns
05-28 19:45:04.294: D/dalvikvm(793): GC_FOR_ALLOC freed 81K, 6% free 2642K/2784K, paused 26ms, total 27ms
05-28 19:45:04.294: I/dalvikvm-heap(793): Grow heap (frag case) to 3.318MB for 714016-byte allocation
05-28 19:45:04.334: D/dalvikvm(793): GC_FOR_ALLOC freed 2K, 5% free 3337K/3484K, paused 34ms, total 34ms
05-28 19:45:04.414: I/Tag2(793): This is my error msg
05-28 19:45:04.414: D/AndroidRuntime(793): Shutting down VM
05-28 19:45:04.414: W/dalvikvm(793): threadid=1: thread exiting with uncaught exception (group=0x41465700)
05-28 19:45:04.425: E/AndroidRuntime(793): FATAL EXCEPTION: main
05-28 19:45:04.425: E/AndroidRuntime(793): java.lang.RuntimeException: Unable to start activity ComponentInfo{xela.kasea.flyffresell/xela.kasea.flyffresell.Main}: java.lang.NullPointerException
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.os.Looper.loop(Looper.java:137)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread.main(ActivityThread.java:5103)
05-28 19:45:04.425: E/AndroidRuntime(793):  at java.lang.reflect.Method.invokeNative(Native Method)
05-28 19:45:04.425: E/AndroidRuntime(793):  at java.lang.reflect.Method.invoke(Method.java:525)
05-28 19:45:04.425: E/AndroidRuntime(793):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-28 19:45:04.425: E/AndroidRuntime(793):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-28 19:45:04.425: E/AndroidRuntime(793):  at dalvik.system.NativeStart.main(Native Method)
05-28 19:45:04.425: E/AndroidRuntime(793): Caused by: java.lang.NullPointerException
05-28 19:45:04.425: E/AndroidRuntime(793):  at xela.kasea.flyffresell.Main.onCreate(Main.java:31)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.Activity.performCreate(Activity.java:5133)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-28 19:45:04.425: E/AndroidRuntime(793):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
05-28 19:45:04.425: E/AndroidRuntime(793):  ... 11 more
05-28 19:45:04.433: W/ActivityManager(274):   Force finishing activity xela.kasea.flyffresell/.Main
05-28 19:45:04.743: I/WindowManager(274): Screenshot max retries 4 of Token{41792b40 ActivityRecord{418a4ce0 u0 xela.kasea.flyffresell/.Main}} appWin=Window{41943b50 u0 Starting xela.kasea.flyffresell} drawState=4
05-28 19:45:04.743: W/WindowManager(274): Screenshot failure taking screenshot for (400x800) to layer 21010
05-28 19:45:05.133: D/AlertService(580): Beginning updateAlertNotification
05-28 19:45:05.214: D/AlertService(580): No fired or scheduled alerts
05-28 19:45:05.263: W/ActivityManager(274): Activity pause timeout for ActivityRecord{418a4ce0 u0 xela.kasea.flyffresell/.Main}
05-28 19:45:05.593: D/AlertService(580): Scheduling next alarm with AlarmScheduler. sEventReminderReceived: null
05-28 19:45:05.853: D/AlarmScheduler(580): No events found starting within 1 week.
05-28 19:45:06.503: I/Process(793): Sending signal. PID: 793 SIG: 9
05-28 19:45:06.513: I/ActivityManager(274): Process xela.kasea.flyffresell (pid 793) has died.

and heres my main.java. Note: i am only using one class.

package xela.kasea.flyffresell;


import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class Main extends Activity implements OnClickListener{

    EditText perin, amountPrUnit, buy, sell;
    ToggleButton lazy;
    Button clear, submit, ret;
    double ans, subAnswer;
    TextView pEarned, tAmount;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.display);
        Log.i("Tag2", "This is my error msg");
        initalizer();
        lazy.setOnClickListener(this);
        clear.setOnClickListener(this);
        submit.setOnClickListener(this);
        ret.setOnClickListener(this);
        /*String a = perin.getText().toString();
        String b = amountPrUnit.getText().toString();
        String c = buy.getText().toString();
        String d = sell.getText().toString(); */
    }

    private void initalizer() {
        // TODO Auto-generated method stub
        perin = (EditText) findViewById(R.id.etHowRich);
        amountPrUnit =  (EditText) findViewById(R.id.etAmountPrUnit);
        buy = (EditText) findViewById(R.id.etBuying);
        sell = (EditText) findViewById(R.id.etSellingPrUnit);
        lazy = (ToggleButton) findViewById(R.id.tbBuying);
        clear = (Button) findViewById(R.id.bClear);
        submit = (Button) findViewById(R.id.bSubmit);
        ret = (Button) findViewById(R.id.bReturn);
        pEarned = (TextView) findViewById(R.id.tvEarned);
        tAmount = (TextView) findViewById(R.id.tvAmount);
        /*int a = Integer.parseInt(perin.getText().toString());
        int b = Integer.parseInt(amountPrUnit.getText().toString());
        int c = Integer.parseInt(buy.getText().toString());
        int d = Integer.parseInt(sell.getText().toString());*/
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        int a = Integer.parseInt(perin.getText().toString());
        int b = Integer.parseInt(amountPrUnit.getText().toString());
        int c = Integer.parseInt(buy.getText().toString());
        int d = Integer.parseInt(sell.getText().toString());
        switch(v.getId()){
        case R.id.bClear:
            perin.setText("");
            amountPrUnit.setText("");
            buy.setText("");
            sell.setText("");
            lazy.setChecked(false);
            break;
        case R.id.bReturn:
            setContentView(R.layout.display);
            break;
        case R.id.bSubmit:
            pEarned.setText(c*d-(a-(b*c)));
            tAmount.setText(c*d+(a-(a-(b*c))));
            setContentView(R.layout.finish);
            break;
        case R.id.tbBuying:
            if (lazy.isChecked()){
            buy.setText("");
            double subAnswer = 0;
            int ans = 0;
            subAnswer = a/b;
            ans = (int) Math.floor(subAnswer);
            /*new Integer((int) ans).toString();
            Integer.toString(answer);*/
            buy.setText(ans);;
            }
            break;
        }
    }
}

what this app is suppose to do is, take a couple of user inputted numbers and do some math with them.

and if you need it, heres the manifest

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

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Main"
            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>

解决方案

I think this comment from the user requires an answer that explains the fundamental topic of what null is in Java:

if i may ask, whats a NullPointerException?

null pointer means that you are trying to manipulate an Object variable that does not have any memory allocated to it. The NullPointerException is Java's way of telling you: "Hey, the variable that you are trying to manipulate (i.e. set a listener to) is pointing to no memory location; there was no Object instantiated for this variable or it was already garbage collected. You are trying to go to use the bathroom of a building that hasn't been built yet."

The stacktrace is nice (you should be friends with him) and tells us in which line of our code the Exception is thrown:

05-28 19:45:04.425: E/AndroidRuntime(793): Caused by: java.lang.NullPointerException 
05-28 19:45:04.425: E/AndroidRuntime(793):  at xela.kasea.flyffresell.Main.onCreate(Main.java:31)

This means that you need to go and check that line of code and figure out which variable is null. Most modern IDE's have the option of introducing breakpoints that allow you to see a variable's state at runtime. Once you know which variable is null you can more easily figure out why. So in your case, the line causing problems is line 31 of Main.java. From the comments we know you said that line is:

ret.setOnClickListender(this);

That leave us with one option; ret has to be null. Then we ask ourselves:

What can happen, under normal conditions, that can make ret be null?

1) The variable is not initialized; we forgot to initialize it. Not our case.

2) The variable was garbaged collected. Not our case.

3) Something went wrong when we tried to initialize our variable. Probably our case.

In this case, we do not initialize the variable by calling the constructor of some class, we do it via a method (i.e. findViewById()). This method takes an int that should be the id of the View we want to set ret to, and it either returns null or the View in question. So, if thought this out correctly, the error probably is that we used the wrong id.

This answer is more to show a thinking pattern rather than an actual solution since there really is not enough information to solve the problem.

这篇关于不幸的是&LT;的applicationName&GT;已经停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆