0

Android SDK を使用して Eclipse で Android アプリケーションに取り組んでいますが、理解できないこれらのエラーが引き続き発生します (これは Android 用の最初のアプリケーションです)。ファイルなので、読者であるあなたにこのすべてを押し付けたくはありませんが、出力は次のとおりです。

    12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.os.Looper.loop(Looper.java:137)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.main(ActivityThread.java:4745)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Method.invokeNative(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Method.invoke(Method.java:511)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-27 13:01:07.872: E/AndroidRuntime(621):  at dalvik.system.NativeStart.main(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Activity.setContentView(Activity.java:1867)
12-27 13:01:07.872: E/AndroidRuntime(621):  at com.chuggle.clink.MainActivity.onCreate(MainActivity.java:31)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Activity.performCreate(Activity.java:5008)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 11 more
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: java.lang.reflect.InvocationTargetException
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-27 13:01:07.872: E/AndroidRuntime(621):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 24 more
12-27 13:01:07.872: E/AndroidRuntime(621): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.content.res.Resources.loadDrawable(Resources.java:1892)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.View.<init>(View.java:3336)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.view.ViewGroup.<init>(ViewGroup.java:427)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.widget.LinearLayout.<init>(LinearLayout.java:176)
12-27 13:01:07.872: E/AndroidRuntime(621):  at android.widget.LinearLayout.<init>(LinearLayout.java:172)
12-27 13:01:07.872: E/AndroidRuntime(621):  ... 27 more
12-27 13:01:12.192: I/Process(621): Sending signal. PID: 621 SIG: 9


XML:

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" android:permission="android.permission.NFC" android:enabled="true" android:debuggable="true">
        <activity
            android:name="com.chuggle.clink.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>

ジャワ:

package com.chuggle.clink;
import java.util.Calendar;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter.MalformedMimeTypeException;
import android.nfc.FormatException;
import android.nfc.NdefMessage;
import android.nfc.NfcAdapter;
import android.nfc.tech.NfcF;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
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 MainActivity extends Activity {
    NfcAdapter nfcAdapter;
    private PendingIntent pint;
    private IntentFilter[] mesfilt;
    private String[][] TList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText messageholder = (EditText) findViewById(R.id.ToSend);
        final Button TButton = (ToggleButton) findViewById(R.id.SendButton);
        nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if (nfcAdapter == null) return;
        pint = PendingIntent.getActivity(this, 0,
        new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
        try {
            ndef.addDataType("*/*");
        } catch (MalformedMimeTypeException e) {
            throw new RuntimeException("fail", e);
        }
        mesfilt = new IntentFilter[] {
                ndef,
        };
        TList = new String[][] { new String[] { NfcF.class.getName() } };
        if (nfcAdapter == null) return;
        TButton.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                sendMessage(messageholder.getText().toString());
            }
        });
    }
    String resolveIntent(Intent intent) {
        NdefMessage[] msgs = null;
        if(intent.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)){
            Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            if(rawMsgs!=null){
                msgs = new NdefMessage[rawMsgs.length];
                for(int i=0;i<rawMsgs.length;i++){
                    msgs[i] = (NdefMessage) rawMsgs[i];
                }
            }
        } 
        else {
        return("Recieving Error");
        }
        return msgs.toString();
    }
    public void sendMessage(String OrToSend){
        Calendar rightNow = Calendar.getInstance();
        OrToSend = OrToSend+" --"+rightNow.getTime().toString();
        byte[] textBytes = OrToSend.getBytes();
        NdefMessage MessageToSend = null;
        try {
            MessageToSend = new NdefMessage(textBytes);
        } catch (FormatException e) {
            e.printStackTrace();
            MessageUpdate("Message Error, Cannot Send");
        }
        nfcAdapter.setNdefPushMessage(MessageToSend, this);

    }
    @Override
    public void onResume() {
        super.onResume();
        nfcAdapter.enableForegroundDispatch(this, pint, mesfilt, TList);
    }

    @Override
    public void onNewIntent(Intent intent) {
        Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
        Log.i(intent.toString(), resolveIntent(intent));
    }
    @Override
    public void onPause() {
        super.onPause();
        nfcAdapter.disableForegroundDispatch(this);
    }
    public void MessageUpdate(String NewString){
        TextView M1 = (TextView)findViewById(R.id.M1);
        TextView M2 = (TextView)findViewById(R.id.M2);
        TextView M3 = (TextView)findViewById(R.id.M3);
        TextView M4 = (TextView)findViewById(R.id.M4);
        TextView M5 = (TextView)findViewById(R.id.M5);
        TextView M6 = (TextView)findViewById(R.id.M6);
        TextView M7 = (TextView)findViewById(R.id.M7);
        TextView M8 = (TextView)findViewById(R.id.M8);
        TextView M9 = (TextView)findViewById(R.id.M9);
        TextView M10 = (TextView)findViewById(R.id.M10);
        TextView M11 = (TextView)findViewById(R.id.M11);
        TextView M12 = (TextView)findViewById(R.id.M12);
        TextView M13 = (TextView)findViewById(R.id.M13);
        TextView M14 = (TextView)findViewById(R.id.M14);
        TextView M15 = (TextView)findViewById(R.id.M15);
        TextView M16 = (TextView)findViewById(R.id.M16);
        TextView M17 = (TextView)findViewById(R.id.M17);
        TextView M18 = (TextView)findViewById(R.id.M18);
        TextView M19 = (TextView)findViewById(R.id.M19);
        TextView M20 = (TextView)findViewById(R.id.M20);
        TextView M21 = (TextView)findViewById(R.id.M21);
        M21.setText(M20.getText());
        M20.setText(M19.getText());
        M19.setText(M18.getText());
        M18.setText(M17.getText());
        M17.setText(M16.getText());
        M16.setText(M15.getText());
        M15.setText(M14.getText());
        M14.setText(M13.getText());
        M13.setText(M12.getText());
        M12.setText(M11.getText());
        M11.setText(M10.getText());
        M10.setText(M9.getText());
        M9.setText(M8.getText());
        M8.setText(M7.getText());
        M7.setText(M6.getText());
        M6.setText(M5.getText());
        M4.setText(M3.getText());
        M2.setText(M1.getText());
        M1.setText(NewString);
    }
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}


申し訳ありませんが、すべて非常に醜いです。ほとんどのコードがかなり間違っていると確信していますが、それは私が気にかけている部分ではありません。お気軽にそれについて助けてください。しかし、本当に私が知る必要があるのは、これらのエラーがなぜ発生するのかです発生し、それらを修正する方法。申し訳ありませんが、これは大規模な投稿です。ありがとう。

4

1 に答える 1