Android(アンドロイド)Eclipseエラー&警告対応

エラー

Incorrect line ending: found carriage return (\r) without corresponding newline (\n)

レイアウトのxml画面で「Ctrl + Shift + F」を押してから保存すればOK。

エラー

Failed to load the LayoutLib: com.android.layoutlib.bridge.Bridge$PostInflateException

クリーンしてEclipseを再起動すればOK。

コンパイルエラー

Your project contains error(s),please fix them begore running your application

クリーンしてEclipseを再起動すればOK。

Eclipse起動時にクリーン(cleanコマンド)を実行する方法

C:\eclipse\eclipse.exe -clean

アイコンを右クリックし「プロパティ>ショートカット(タブ)>リンク先」を上記のように変更してから実行。

エラー

Failure 5 (database is locked) on 0x[6桁の16進数] when executing 'BEGIN EXCLUSIVE;'

同一メソッドでの書き込み処理が衝突しないように修正すればOK。

書き込みエラー

.classpathに書き込めませんでした

エクスプローラーから.classpathの隠しファイルのチェックを外せばOK。

Lintエラーチェック

is not translated in
Export aborted because fatal lint errors were found.

string.xmlを各国語用にも作ってよというエラー。Lintのエラーチェックを緩めればOK。

エラー

NotFoundException: null
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- TextView (Change to android.widget.TextView, Fix Build Path, Edit XML)

グラフィカルレイアウトのAPIバージョンを(古いバージョンに)下げればOK。

エラー

1oku.png
100ten.png

Androidのリソースファイル名が上記のように数値から始まっているとエラーになる。

警告

This ScrollView layout or its LinearLayout parent is possibly useless

このスクロールViewか親のViewが無駄。消すべき。

警告

This LinearLayout layout or its LinearLayout parent is useless

無駄に何度もLinearLayoutで括ってる。無駄を省けばOK。

警告

Use a layout_height of 0dip instead of wrap_content for better performance

"wrap_content"ではなく、"0dip"にすればOK。

警告

Missing contentDescription attribute on image

画像が表示できない場合の代わりの文字列を定義してないと出る。

android:contentDescription="@string/desc"

上記のようにstring.xmlに定義または直接記入すればOK。

メモリ不足警告

Unable to execute dex: Java heap space Java heap space

eclipse.iniの一番下の数値を増やせばOK(512mから1024mなどにする)

toUpperCaseに警告が出る

Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead

デフォルトのロケールを使用していると出る。

toLowerCase(Locale.ENGLISH)

として保存しEclipseを再起動すればOK。