DRYな備忘録

Don't Repeat Yourself.

とりあえず簡単なAndroidアプリをつくってみる【Android Studio】

ゴール

  • AndroidStudioをインストール
  • Androidプロジェクトを新規作成
  • シミュレータでアプリを起動
  • 実機でアプリを起動

f:id:otiai10:20140913204053p:plain

AndroidStudioをインストール

Androidプロジェクトを新規作成

f:id:otiai10:20140913164713j:plain

※ 僕はプロジェクトを~/proj/{種類}/{プロジェクト名}に置くようにしてるので↑

f:id:otiai10:20140913164907j:plain

※ 手元にある実機が4.4なので4.4にしときます↑

f:id:otiai10:20140913165620j:plain

※ たぶんデフォルトのblankってやつでいい。activityってなんぞ?

f:id:otiai10:20140913165654j:plain

※ 知らねえよ早くつくれよ、という気持ち

f:id:otiai10:20140913165732j:plain

  • できた...!

シミュレータでアプリを起動

  • Hello, worldのまんまとりあえず起動したい
  • 上のバーにある緑の再生ボタンを押します
  • 「デバイス選べ」って言われるので、下のLaunch Emulatorにチェックを入れて
  • 手元の実機がNexus5なので、それを見越してNexus5にしときます

f:id:otiai10:20140913170322j:plain

  • 意気揚々とOK!

f:id:otiai10:20140913170914j:plain

f:id:otiai10:20140913174048j:plain

f:id:otiai10:20140913174254j:plain

  • なるほど4.4のSystem ImageがNot Installed
  • チェックボックス入れて
  • 右下のInstall packagesをクリック
  • なんか同意してさらにInstallをクリック
  • 待つ(けっこう待つ)



  • インストールできたので、同様にRunしてみると...

f:id:otiai10:20140913175614j:plain


f:id:otiai10:20140913175614j:plain



f:id:otiai10:20140913175614j:plain




f:id:otiai10:20140913175614j:plain





いくら待っても立ち上がらない

早くできるらしいです

OKやってみる

f:id:otiai10:20140913175913j:plain

よし、これならどうだ!

f:id:otiai10:20140913175933j:plain

...


糞い

結論:
エミュレータやめろ。実機つかえ



実機でアプリを起動

f:id:otiai10:20140913205150j:plain

  • これなので、これにむけてRunすると

f:id:otiai10:20140913205248j:plain

味気ないので、以下の変更を加えた

diff --git a/app/src/main/res/layout/activity_my.xml b/app/src/main/res/layout/activity_my.xml
index c17166f..a742a5b 100644
--- a/app/src/main/res/layout/activity_my.xml
+++ b/app/src/main/res/layout/activity_my.xml
@@ -9,8 +9,10 @@
     tools:context=".MyActivity">

     <TextView
-        android:text="@string/hello_world"
+        android:text="田井中律は\n俺の嫁"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content" />
+        android:layout_height="wrap_content"
+        android:textSize="100dp"
+    />

 </RelativeLayout>

f:id:otiai10:20140913205231j:plain

イェーイ

雑感

エミュレータやめろ。実機つかえ

ほんまこれ

DRYな備忘録