-1

デバッガーは何も問題を見つけることができず、アプリはまだ起動しません。logcatとコードは次のとおりです。

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

@SuppressLint("UseValueOf") public  class MainActivity extends Activity  {
protected Double value1;
protected Double value2;
protected Double value3;
protected Double delta;
protected Double x1;
protected Double x2;
final EditText tf1 = (EditText)findViewById(R.id.editText1);
final EditText tf2 = (EditText)findViewById(R.id.editText2);
final EditText tf3 = (EditText)findViewById(R.id.editText3);
final TextView result1 = (TextView) findViewById(R.id.textView4);
final TextView result2 = (TextView) findViewById(R.id.textView6);
final Button caculate = (Button) findViewById(R.id.button1);


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

    tf1.setOnFocusChangeListener(new OnFocusChangeListener() {          

        public void onFocusChange(View v, boolean hasFocus) {
            if(!hasFocus)
                setTextToString1();
        }
    });

    tf2.setOnFocusChangeListener(new OnFocusChangeListener() {          

        public void onFocusChange(View v, boolean hasFocus) {
            if(!hasFocus)
                setTextToString2();
        }
    });

    tf3.setOnFocusChangeListener(new OnFocusChangeListener()
    {          

        public void onFocusChange(View v, boolean hasFocus)
        {
            if(!hasFocus)
                setTextToString3();
        }

    }); 

caculate.setOnClickListener(null);
{
    if( !(value3.equals(null)&&value2.equals(null)&&value3.equals(null))  )
    {
        delta = new Double(caculateDelta(value1,value2,value3));
        x1 = caculateX(Math.sqrt(delta.doubleValue()));
        x2 =caculateX(-Math.sqrt(delta.doubleValue()));
        result1.setText(x1.toString());
        result2.setText(x2.toString());
    }
    else
    {
        result1.setText("Error");
        result2.setText("Error");
    }
}

}



public void setTextToString1()
{
    value1 = new Double(Integer.parseInt(tf1.getText().toString()));
}
@SuppressLint("UseValueOf") public void setTextToString2()
{
    value2 = new Double( Integer.parseInt(tf2.getText().toString()));   
    }
public void setTextToString3()
{
    value3 = new Double( Integer.parseInt(tf3.getText().toString()));
}

public double caculateDelta (double a, double b , double c)
{
    return b*b-(4*a*c);
}
public double caculateX (Double delta)
{
    return (-value2+delta.doubleValue()/(2*value1));
}

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

}

これがlogcatです。logcat全体を削除してアプリを再起動し、そのlogcatをコピーしました。

03-22 19:57:47.946: D/AndroidRuntime(788): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
03-22 19:57:47.946: D/AndroidRuntime(788): CheckJNI is ON
03-22 19:57:48.036: D/dalvikvm(788): Trying to load lib libjavacore.so 0x0
03-22 19:57:48.057: D/dalvikvm(788): Added shared lib libjavacore.so 0x0
03-22 19:57:48.135: D/dalvikvm(788): Trying to load lib libnativehelper.so 0x0
03-22 19:57:48.135: D/dalvikvm(788): Added shared lib libnativehelper.so 0x0
03-22 19:57:49.786: D/AndroidRuntime(788): Calling main entry com.android.commands.pm.Pm
03-22 19:57:49.916: I/ActivityManager(299): Start proc com.android.defcontainer for service com.android.defcontainer/.DefaultContainerService: pid=799 uid=10009 gids={50009, 1015, 2001, 1028}
03-22 19:57:50.176: E/Trace(799): error opening trace file: No such file or directory (2)
03-22 19:57:50.446: W/ActivityManager(299): No content provider found for permission revoke: file:///data/local/tmp/SqureFunC.apk
03-22 19:57:50.836: W/ActivityManager(299): No content provider found for permission revoke: file:///data/local/tmp/SqureFunC.apk
03-22 19:57:50.836: I/PackageManager(299): Copying native libraries to /data/app-lib/vmdl1616084389
03-22 19:57:51.416: I/PackageManager(299): Removing non-system package:com.eilonudi.squrefunc
03-22 19:57:51.416: I/ActivityManager(299): Force stopping package com.eilonudi.squrefunc appid=10046 user=-1
03-22 19:57:52.027: I/PackageManager(299): Package com.eilonudi.squrefunc codePath changed from /data/app/com.eilonudi.squrefunc-2.apk to /data/app/com.eilonudi.squrefunc-1.apk; Retaining data and using new
03-22 19:57:52.081: I/PackageManager(299): Running dexopt on: com.eilonudi.squrefunc
03-22 19:57:54.766: D/dalvikvm(813): DexOpt: load 383ms, verify+opt 1197ms, 800436 bytes
03-22 19:57:55.036: I/ActivityManager(299): Force stopping package com.eilonudi.squrefunc appid=10046 user=-1
03-22 19:57:55.066: W/PackageManager(299): Code path for pkg : com.eilonudi.squrefunc changing from /data/app/com.eilonudi.squrefunc-2.apk to /data/app/com.eilonudi.squrefunc-1.apk
03-22 19:57:55.066: W/PackageManager(299): Resource path for pkg : com.eilonudi.squrefunc changing from /data/app/com.eilonudi.squrefunc-2.apk to /data/app/com.eilonudi.squrefunc-1.apk
03-22 19:57:55.926: D/dalvikvm(299): GC_CONCURRENT freed 529K, 25% free 5371K/7116K, paused 95ms+21ms, total 295ms
03-22 19:57:55.996: D/PackageManager(299): New package installed in /data/app/com.eilonudi.squrefunc-1.apk
03-22 19:57:56.266: I/ActivityManager(299): Force stopping package com.eilonudi.squrefunc appid=10046 user=0
03-22 19:57:56.566: D/dalvikvm(419): GC_EXPLICIT freed 106K, 16% free 3821K/4504K, paused 9ms+14ms, total 134ms
03-22 19:57:56.756: I/InputReader(299): Reconfiguring input devices.  changes=0x00000010
03-22 19:57:56.796: I/ActivityManager(299): Start proc com.android.keychain for broadcast com.android.keychain/.KeyChainBroadcastReceiver: pid=815 uid=1000 gids={41000, 1015, 1028, 3002, 3001, 3003}
03-22 19:57:57.126: E/Trace(815): error opening trace file: No such file or directory (2)
03-22 19:57:57.226: W/ContextImpl(815): Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1352 android.content.ContextWrapper.startService:450 android.content.ContextWrapper.startService:450 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2376 
03-22 19:57:57.316: W/AccountTypeManager(602): No authenticator found for type=com.android.exchange, ignoring it.
03-22 19:57:57.326: I/AccountTypeManager(602): Loaded meta-data for 0 account types, 0 accounts in 12ms(wall) 6ms(cpu)
03-22 19:57:57.356: D/dalvikvm(453): GC_EXPLICIT freed 263K, 13% free 2708K/3108K, paused 13ms+14ms, total 1060ms
03-22 19:57:57.786: I/InputReader(299): Reconfiguring input devices.  changes=0x00000010
03-22 19:57:58.376: W/InputMethodManagerService(299): Found no subtypes in a system IME: com.android.inputmethod.pinyin
03-22 19:57:58.456: W/AccountTypeManager(602): No authenticator found for type=com.android.exchange, ignoring it.
03-22 19:57:58.466: I/AccountTypeManager(602): Loaded meta-data for 0 account types, 0 accounts in 14ms(wall) 7ms(cpu)
03-22 19:57:58.556: I/ActivityManager(299): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=829 uid=10014 gids={50014, 1015, 1028}
03-22 19:57:58.796: D/dalvikvm(37): GC_EXPLICIT freed 38K, 8% free 2369K/2552K, paused 8ms+9ms, total 256ms
03-22 19:57:58.986: D/dalvikvm(37): GC_EXPLICIT freed <1K, 8% free 2369K/2552K, paused 13ms+18ms, total 190ms
03-22 19:57:59.096: E/Trace(829): error opening trace file: No such file or directory (2)
03-22 19:57:59.206: D/dalvikvm(37): GC_EXPLICIT freed <1K, 8% free 2369K/2552K, paused 23ms+19ms, total 217ms
03-22 19:58:00.916: D/dalvikvm(299): GC_EXPLICIT freed 629K, 25% free 5340K/7116K, paused 75ms+102ms, total 1519ms
03-22 19:58:01.216: D/AndroidRuntime(788): Shutting down VM
03-22 19:58:01.296: D/dalvikvm(788): GC_CONCURRENT freed 94K, 18% free 467K/564K, paused 11ms+2ms, total 52ms
03-22 19:58:01.296: D/jdwp(788): Got wake-up signal, bailing out of select
03-22 19:58:01.296: D/dalvikvm(788): Debugger has detached; object registry had 1 entries
03-22 19:58:01.878: I/ActivityManager(299): Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.CorporaUpdateReceiver: pid=848 uid=10001 gids={50001, 3003, 1028}
03-22 19:58:02.596: E/Trace(848): error opening trace file: No such file or directory (2)
03-22 19:58:03.256: D/AndroidRuntime(852): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
03-22 19:58:03.256: D/AndroidRuntime(852): CheckJNI is ON
03-22 19:58:03.436: D/dalvikvm(852): Trying to load lib libjavacore.so 0x0
03-22 19:58:03.487: D/dalvikvm(852): Added shared lib libjavacore.so 0x0
03-22 19:58:03.506: W/RecognitionManagerService(299): no available voice recognition services found for user 0
03-22 19:58:03.616: I/Choreographer(419): Skipped 1174 frames!  The application may be doing too much work on its main thread.
03-22 19:58:03.627: D/dalvikvm(852): Trying to load lib libnativehelper.so 0x0
03-22 19:58:03.627: D/dalvikvm(852): Added shared lib libnativehelper.so 0x0
03-22 19:58:03.996: I/Choreographer(419): Skipped 37 frames!  The application may be doing too much work on its main thread.
03-22 19:58:05.726: D/AndroidRuntime(852): Calling main entry com.android.commands.am.Am
03-22 19:58:05.746: D/dalvikvm(852): Note: class Landroid/app/ActivityManagerNative; has 157 unimplemented (abstract) methods
03-22 19:58:05.837: I/ActivityManager(299): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.eilonudi.squrefunc/.MainActivity} from pid 852
03-22 19:58:05.909: D/PermissionCache(36): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (14464 us)
03-22 19:58:05.926: W/WindowManager(299): Failure taking screenshot for (164x246) to layer 21005
03-22 19:58:06.017: D/AndroidRuntime(852): Shutting down VM
03-22 19:58:06.067: D/dalvikvm(873): Not late-enabling CheckJNI (already on)
03-22 19:58:06.117: I/ActivityManager(299): Start proc com.eilonudi.squrefunc for activity com.eilonudi.squrefunc/.MainActivity: pid=873 uid=10046 gids={50046, 1028}
03-22 19:58:06.117: D/dalvikvm(852): GC_CONCURRENT freed 95K, 17% free 499K/596K, paused 2ms+7ms, total 75ms
03-22 19:58:06.128: D/jdwp(852): Got wake-up signal, bailing out of select
03-22 19:58:06.128: D/dalvikvm(852): Debugger has detached; object registry had 1 entries
03-22 19:58:06.786: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-22 19:58:07.046: I/Choreographer(299): Skipped 41 frames!  The application may be doing too much work on its main thread.
03-22 19:58:07.156: I/Choreographer(299): Skipped 46 frames!  The application may be doing too much work on its main thread.
03-22 19:58:07.366: E/Trace(873): error opening trace file: No such file or directory (2)
03-22 19:58:07.756: I/Choreographer(299): Skipped 34 frames!  The application may be doing too much work on its main thread.
03-22 19:58:08.046: I/Choreographer(419): Skipped 76 frames!  The application may be doing too much work on its main thread.
03-22 19:58:08.296: I/try(873): start view
03-22 19:58:08.336: D/AndroidRuntime(873): Shutting down VM
03-22 19:58:08.336: W/dalvikvm(873): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
03-22 19:58:08.376: E/AndroidRuntime(873): FATAL EXCEPTION: main
03-22 19:58:08.376: E/AndroidRuntime(873): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eilonudi.squrefunc/com.eilonudi.squrefunc.MainActivity}: java.lang.NullPointerException
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.os.Looper.loop(Looper.java:137)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread.main(ActivityThread.java:5041)
03-22 19:58:08.376: E/AndroidRuntime(873):  at java.lang.reflect.Method.invokeNative(Native Method)
03-22 19:58:08.376: E/AndroidRuntime(873):  at java.lang.reflect.Method.invoke(Method.java:511)
03-22 19:58:08.376: E/AndroidRuntime(873):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-22 19:58:08.376: E/AndroidRuntime(873):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-22 19:58:08.376: E/AndroidRuntime(873):  at dalvik.system.NativeStart.main(Native Method)
03-22 19:58:08.376: E/AndroidRuntime(873): Caused by: java.lang.NullPointerException
03-22 19:58:08.376: E/AndroidRuntime(873):  at com.eilonudi.squrefunc.MainActivity.onCreate(MainActivity.java:69)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.Activity.performCreate(Activity.java:5104)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-22 19:58:08.376: E/AndroidRuntime(873):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-22 19:58:08.376: E/AndroidRuntime(873):  ... 11 more
03-22 19:58:08.416: W/ActivityManager(299):   Force finishing activity com.eilonudi.squrefunc/.MainActivity
03-22 19:58:08.486: W/WindowManager(299): Failure taking screenshot for (164x246) to layer 21010
03-22 19:58:09.016: W/ActivityManager(299): Activity pause timeout for ActivityRecord{40e98aa0 u0 com.eilonudi.squrefunc/.MainActivity}
03-22 19:58:09.066: I/Choreographer(299): Skipped 156 frames!  The application may be doing too much work on its main thread.
03-22 19:58:09.136: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-22 19:58:09.526: I/Choreographer(419): Skipped 303 frames!  The application may be doing too much work on its main thread.
03-22 19:58:09.727: I/Choreographer(299): Skipped 63 frames!  The application may be doing too much work on its main thread.
03-22 19:58:09.826: I/ARMAssembler(36): generated scanline__00000077:03515104_00008001_00000000 [113 ipp] (134 ins) at [0x40eb3460:0x40eb3678] in 2950837 ns
03-22 19:58:09.896: I/Choreographer(299): Skipped 55 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.006: I/Choreographer(299): Skipped 50 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.216: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-22 19:58:10.396: I/Choreographer(299): Skipped 46 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.416: I/Choreographer(299): Skipped 58 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.526: I/Choreographer(299): Skipped 47 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.586: I/Choreographer(299): Skipped 37 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.696: I/Choreographer(299): Skipped 72 frames!  The application may be doing too much work on its main thread.
03-22 19:58:10.776: I/Choreographer(299): Skipped 30 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.016: I/Choreographer(299): Skipped 36 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.086: I/Choreographer(299): Skipped 36 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.206: I/Choreographer(299): Skipped 66 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.326: D/dalvikvm(299): GC_CONCURRENT freed 208K, 19% free 5785K/7116K, paused 14ms+83ms, total 1881ms
03-22 19:58:11.326: I/Choreographer(299): Skipped 46 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.776: I/Choreographer(299): Skipped 33 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.806: I/Choreographer(299): Skipped 59 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.856: I/Choreographer(299): Skipped 49 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.896: D/dalvikvm(419): GC_FOR_ALLOC freed 201K, 16% free 3815K/4504K, paused 656ms, total 700ms
03-22 19:58:11.958: I/Choreographer(299): Skipped 63 frames!  The application may be doing too much work on its main thread.
03-22 19:58:11.996: I/Choreographer(299): Skipped 76 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.059: I/Choreographer(299): Skipped 53 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.086: I/Choreographer(299): Skipped 49 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.156: I/Process(873): Sending signal. PID: 873 SIG: 9
03-22 19:58:12.196: I/ActivityManager(299): Process com.eilonudi.squrefunc (pid 873) has died.
03-22 19:58:12.226: I/Choreographer(299): Skipped 122 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.366: I/Choreographer(299): Skipped 167 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.576: I/Choreographer(299): Skipped 55 frames!  The application may be doing too much work on its main thread.
03-22 19:58:12.756: I/Choreographer(299): Skipped 79 frames!  The application may be doing too much work on its main thread.
03-22 19:58:13.076: I/Choreographer(299): Skipped 35 frames!  The application may be doing too much work on its main thread.
03-22 19:58:13.236: W/InputMethodManagerService(299): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4107b340 attribute=null, token = android.os.BinderProxy@40f8fbc8
03-22 19:58:18.206: D/ExchangeService(691): Received deviceId from Email app: null
03-22 19:58:18.206: D/ExchangeService(691): !!! deviceId unknown; stopping self and retrying
4

1 に答える 1

1

まず、setContentViewの後にonCreateメソッドでこれらの行を記述します。

final EditText tf1 = (EditText)findViewById(R.id.editText1);
final EditText tf2 = (EditText)findViewById(R.id.editText2);
final EditText tf3 = (EditText)findViewById(R.id.editText3);
final TextView result1 = (TextView) findViewById(R.id.textView4);
final TextView result2 = (TextView) findViewById(R.id.textView6);
final Button caculate = (Button) findViewById(R.id.button1);

AndroidManifest.xmlにエントリがすべて正しく含まれていることを確認してください。

これらのリンクを参照してください

Android「許可を取り消すコンテンツプロバイダーが見つかりません」

Android4.0ICSにアプリケーションがインストールされていません

于 2013-03-22T15:34:55.267 に答える