質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

2回答

6367閲覧

AndroidStudioでXML or text declaration not at start of entityと出ます。

edoooooo

総合スコア476

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

1グッド

0クリップ

投稿2016/05/10 14:56

編集2016/05/11 10:16

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
recode👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

このstartだけカラーにならないのですが、何が問題なのでしょうか?

ケアレスミスでしょうか

xml

1android:id="@+id/cpu_message" /> 2android:layout_gravity="start"/>

android:id="@+id/cpu_message"の
/> はいりませんね

投稿2016/05/11 06:27

aja

総合スコア3733

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

edoooooo

2016/05/11 06:39

ありがとうございます。 />の削除によりandroid:layou_gravity="start"/>に色はついたのですが、実行してみると同じエラーとなります。どうぞよろしくお願いします。
guest

0

ベストアンサー

xmlはルートタグの属性でAndroid向けタグの定義を読み込まないといけません。
下記の属性はルートタグにありますか?

xml

1xmlns:android="http://schemas.android.com/apk/res/android"

投稿2016/05/10 17:54

yona

総合スコア18155

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

edoooooo

2016/05/11 06:40

ありがとうございます。 ご指摘いただいたコードは、コードの中に記載されておりました。 コードをのせました。どうぞよろしくお願いします。
yona

2016/05/11 07:37

そもそもビルドが通らないですよね。 findByIdはfindViewByIdの誤りではないですか。
edoooooo

2016/05/11 08:20

ありがとうございます。 findByIdは解決しました。他にもすべてのRが赤くなっており、そのシンボルは解決できませんと出ます。 こちらはどのようにしていすればいいのでしょうか?すみません どうぞよろしくお願いします。
yona

2016/05/11 08:32

Rが赤いのはリソース関係のエラーがある場合にR.javaが生成されないからです。 app:layout_behaivorとtool:showInを消してみるとどうなりますか?
edoooooo

2016/05/11 08:48

ありがとうございます。 エラーがすべてに先行して、宣言してくださいと表示されました。 その下には分析が完了しました。とわからないエラーも出ました。 Analysis Completed 1 errorfound 1 warningfound エラーの写真も変更しました。 すみません。どうぞよろしくお願いします。
yona

2016/05/11 08:57

プロジェクトのxmlのどれかで記述ミスがある様です。 ajaさんが指摘している様なミスが他にもありそうなので、すべてのxmlを見直す必要があります。
edoooooo

2016/05/11 09:13

ありがとうございます。xmlns:app="http://schemas.android.com/apk/res-auto" が薄黒字となっていたので消去した所 1errorfoud となり 1warnningfoundがなくなりました。もう一つを探してみます。
yona

2016/05/11 09:29

lintを見るとヒントがあるかもしれないですね。
edoooooo

2016/05/11 09:51

ありがとうございます。 Analyze からinspect codeでWhole projectで開いたのですが、 自分のいじってた、chatapilittion、の1item と書いてあり、そこには On SDK version 23 and up, your app data will be automatically backed up and restored on app install. Consider adding the attribute 'android:fullBackupContent' to specify an '@xml' resource which configures which files to backup. More info: https://developer.android.com/preview/backup/index.html と出てきました。 installに問題があるということなのでしょうか?
yona

2016/05/11 10:09

なぜ、installが怪しいと思ったのかを書いてください。ポンっとそんなことを言われてもわかりません。説明をしてください。 マニフェストファイルが怪しいので質問に追記してください。
edoooooo

2016/05/11 10:15

install時に参考としているAndroidの教科書という本と同じ画面が出ず、installできてないものがあり、contentTreeも本のようにdefaultがなっていなかったためです。 マニュフェストファイルを追加します。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問