試しに空っぽのプロジェクトでビルドしてみると、ビルドはすんなり通りました。ビルドはね!
こんな感じでほとんどデフォルトです。
まずは「New Project...」でプロジェクトの新規作成ウィザードを起動します。
アプリ名等々はてきとうに。Minimum required SDKとTarget SDKはあえてLevel 10に落としてます。
まだまだGingerbread残ってますしね。2014/2/8時点で21.2%らしいです。
それと、カスタムアイコンを用意するのも面倒なのでCreate custom launcher iconのチェックは外しておきます。
あとはそのまま。
これで無事Projectが作成されたので、このままツールバーの三角ボタンを押して実機転送開始!
なんかエラーが起きたらしいです。
何にもコード書いてないよ、テンプレートまんまだよ!?なんでなんで???
ちょっぴりあせりましたが、エラーが起きてるということはlogcatのぞけば何か吐かれているはずです。
居ましたよ、赤い(エラーの色)やつ。
01-17 23:39:53.303 18354-18354/com.helloworld.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.helloworld.app/com.helloworld.app.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1215)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4798)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
at com.helloworld.app.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2043)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1215)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4798)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Theme.AppCompatを使えと言われています。そうですか、自分でやれというんですね。
まだ勝手が分かっていないので、ここは素直に従いましょう。6行目のテーマ設定を追加しました。
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:theme="@style/Theme.AppCompat"
android:name="com.helloworld.app.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>
これでどうよ!
はい、無事動きました。
エラーメッセージ出せばいいってもんじゃないよ。issueなりrelease noteなりをちゃんと確認すればどこかに書いてあったのかもしれないし、そもそもpreiew版だから仕方がないといえばそうなんですよね。
なんにせよ、動いてくれたのでよしとしておきます。







0 件のコメント :
コメントを投稿