java
1Error:(2) Error parsing XML: XML or text declaration not at start of entity
このようにstartの宣言が出来ていませんと出ます。
なぜなのでしょうか?
java
1<?xml version="1.0" encoding="utf-8"?> 2<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:paddingLeft="@dimen/activity_horizontal_margin" 8 android:paddingRight="@dimen/activity_horizontal_margin" 9 android:paddingTop="@dimen/activity_vertical_margin" 10 android:paddingBottom="@dimen/activity_vertical_margin" 11 app:layout_behavior="@string/appbar_scrolling_view_behavior" 12 tools:showIn="@layout/activity_chat" 13 tools:context=".ChatActivity"> 14 15 <EditText 16 android:layout_width="wrap_content" 17 android:layout_height="wrap_content" 18 android:id="@+id/input_message" 19 android:layout_alignParentTop="true" 20 android:layout_alignParentLeft="true" 21 android:layout_alignParentStart="true" 22 android:layout_toLeftOf="@+id/send_message" 23 android:layout_toStartOf="@+id/send_message" /> 24 25 <Button 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:text="SEND" 29 android:id="@+id/send_message" 30 android:layout_alignParentTop="true" 31 android:layout_alignParentRight="true" 32 android:layout_alignParentEnd="true" /> 33 34 <LinearLayout 35 android:orientation="vertical" 36 android:layout_width="fill_parent" 37 android:layout_height="fill_parent" 38 android:layout_below="@+id/input_message" 39 android:layout_alignParentLeft="true" 40 android:layout_alignParentStart="true" 41 android:id="@+id/message_log"> 42 43 <TextView 44 android:layout_width="wrap_content" 45 android:layout_height="wrap_content" 46 android:text="こんにちは" 47 android:id="@+id/cpu_message" 48 android:layout_gravity="start"/> 49 50 <TextView 51 android:layout_width="wrap_content" 52 android:layout_height="wrap_content" 53 android:text="" 54 android:id="@+id/user_message" 55 android:layout_gravity="end" /> 56 </LinearLayout> 57 58</RelativeLayout> 59 60
このようなエラーメッセージも出ます。
java
1Error:Execution failed for task ':chatapplication:processDebugResources'. 2> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/endoutaichi/Library/Android/sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
このonCreateのRが赤文字となってしまいます。
java
1package jp.study.chatapplication; 2 3import android.os.Bundle; 4import android.support.design.widget.FloatingActionButton; 5import android.support.design.widget.Snackbar; 6import android.support.v7.app.AppCompatActivity; 7import android.support.v7.widget.Toolbar; 8import android.view.View; 9import android.view.Menu; 10import android.view.MenuItem; 11import android.widget.Button; 12import android.widget.EditText; 13import android.widget.LinearLayout; 14import android.widget.TextView; 15 16public class ChatActivity extends AppCompatActivity { 17 18 private EditText mInputMessage; 19 private Button mSendMessage; 20 private LinearLayout mMessageLog; 21 private TextView mCpuMessage; 22 private TextView mUserMessage; 23 24 @Override 25 protected void onCreate(Bundle savedInstanceState) { 26 super.onCreate(savedInstanceState); 27 setContentView(R.layout.activity_chat); 28 29 30 31 mInputMessage=(EditText)findViewById(R.id.input_message);//ユーザーが入力するフィールド 32 mSendMessage=(Button)findViewById(R.id.send_message);//SENDボタン 33 mMessageLog=(LinearLayout)findViewById(R.id.message_log);//入力履歴を表示するレイアウト 34 mCpuMessage=(TextView)findViewById(R.id.cpu_message);//コンピューターからの応答 35 mUserMessage=(TextView)findViewById(R.id.user_message);//ユーザーが入力した内容 36 mInputMessage.setText("hoge"); 37 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 38 setSupportActionBar(toolbar); 39 } 40 @Override 41 public boolean onCreateOptionsMenu(Menu menu) { 42 // Inflate the menu; this adds items to the action bar if it is present. 43 getMenuInflater().inflate(R.menu.menu_chat, menu); 44 return true; 45 } 46 47 @Override 48 public boolean onOptionsItemSelected(MenuItem item) { 49 // Handle action bar item clicks here. The action bar will 50 // automatically handle clicks on the Home/Up button, so long 51 // as you specify a parent activity in AndroidManifest.xml. 52 int id = item.getItemId(); 53 54 //noinspection SimplifiableIfStatement 55 if (id == R.id.action_settings) { 56 return true; 57 } 58 59 return super.onOptionsItemSelected(item); 60 } 61} 62
エラーが変わりました。
すべてに先行して、宣言をしてくださいと出ました。
さらに、
Analysis Completed
1 errorfound
1 warningfound となりました。
xml
1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="jp.study.example37" > 4 5 <application 6 android:allowBackup="true" 7 android:icon="@mipmap/ic_launcher" 8 android:label="@string/app_name" 9 android:supportsRtl="true" 10 android:theme="@style/AppTheme" > 11 <activity 12 android:name=".MainActivity" 13 android:label="@string/app_name" 14 android:theme="@style/AppTheme.NoActionBar" > 15 <intent-filter> 16 <action android:name="android.intent.action.MAIN" /> 17 18 <category android:name="android.intent.category.LAUNCHER" /> 19 </intent-filter> 20 </activity> 21 </application> 22 23</manifest> 24
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/11 06:39