新規プロジェクト作成
状態:-
閲覧数:2,797
投稿日:2018-02-26
更新日:2018-03-02
Android Studio を起動
・[Start new Android Studio project] をクリック
[Application name]、[Company domain]、[Project location]を入力し、[Next]をクリック
・※パッケージ名は変更できるが、特に問題なければそのままでよい
[mimimum SDK]は[API 27](現在の最新)を選択
[Next]をクリック
エミュレータの動作確認が目的なので、ここでは[Empty Activity]を選択し、[Next]をクリック
そのまま[Next]をクリック
[Component Installer]画面で、[Done] が表示されたら、[Finish]をクリック
・「アクセスを許可する」ボタンをクリック
最初のProject作成時は、Project作成中に[Tips of this Day]ダイアログがでる
[Close]をクリック
※[Tips of this Day]ダイアログを二度と見たくなければ、[Show Tips on Startup] のチェックを外す
・[Start new Android Studio project] をクリック
[Application name]、[Company domain]、[Project location]を入力し、[Next]をクリック
・※パッケージ名は変更できるが、特に問題なければそのままでよい
項目 | 内容 |
---|---|
Application name: | POC App |
Company domain: | android0.w4c.work |
Project location: | L:/Android/AndroidStudioProject/POCApp |
Package name: | tokyo.w3c.android0.pocapp |
[Next]をクリック
エミュレータの動作確認が目的なので、ここでは[Empty Activity]を選択し、[Next]をクリック
そのまま[Next]をクリック
[Component Installer]画面で、[Done] が表示されたら、[Finish]をクリック
・「アクセスを許可する」ボタンをクリック
最初のProject作成時は、Project作成中に[Tips of this Day]ダイアログがでる
[Close]をクリック
※[Tips of this Day]ダイアログを二度と見たくなければ、[Show Tips on Startup] のチェックを外す
エラー対応
Failed to find target with hash string 'android-26' in: "L:\Android\Sdk
[Install missing platform(s) and sync project] をクリック
・[Accept]を選択して[Next]をクリック
・unzipping
・メチャメチャ時間がかかる
・Component Installer が実行されるので、[Done]が表示されたら[Finish]をクリック
・今度は、「Failed to find Build Tools reision 26.0.2」エラー
・Messages に従って、26.0.2 をインストールする
[Install Build Tools 26.0.2 and sync project] をクリック
[Done]が表示されたら[Finish]をクリック
ビルドが完了
▼MainActivity.java
package tokyo.w3c.android0.pocapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
▼AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tokyo.w3c.android0.pocapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
エミュレータで実行
メニューの[Run]->[Run App]をクリックして実行
最新の「API 27」しか入れてないので、[Nexus 5X API 27 x86]を選択して[OK]をクリック
[OK]をクリック
[NEXT]をクリック
[Finish]をクリック
エミュレータの最初の実行時に起こる警告がある
・次の実行時には表示されないません。
・emulator: ERROR: Missing initial data partition file
エミュレータが起動され、作成した「POC App」アプリが表示された
Android Studio3 Emulatorでアプリを動かそう
最新の「API 27」しか入れてないので、[Nexus 5X API 27 x86]を選択して[OK]をクリック
Intel HAXM is required to run this AVD.
HAXM is not installed.
Install Intel HAXM for better emulation performance.
HAXM is not installed.
Install Intel HAXM for better emulation performance.
[OK]をクリック
[NEXT]をクリック
[Finish]をクリック
エミュレータの最初の実行時に起こる警告がある
・次の実行時には表示されないません。
・emulator: ERROR: Missing initial data partition file
2018/02/28
12:09 Gradle sync started
12:10 Project setup started
12:10 Gradle sync finished in 55s 947ms
12:10 Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
12:11 Gradle build finished in 8s 202ms
12:12 * daemon not running; starting now at tcp:5037
12:12 * daemon started successfully
12:13 Executing tasks: [:app:assembleDebug]
12:16 Emulator: emulator: ERROR: Missing initial data partition file: C:\Users\e1blue\.android\avd\Nexus_5X_API_27_x86.avd/userdata.img
12:16 Emulator: Warning: Quick Boot / Snapshots not supported on this machine. A CPU with EPT + UG features is currently needed. We will address this in a future release.
12:16 Emulator: audio: Failed to create voice `goldfish_audio_in'
12:16 Emulator: qemu-system-x86_64.exe: warning: opening audio input failed
12:16 Emulator: audio: Failed to create voice `adc'
12:09 Gradle sync started
12:10 Project setup started
12:10 Gradle sync finished in 55s 947ms
12:10 Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
12:11 Gradle build finished in 8s 202ms
12:12 * daemon not running; starting now at tcp:5037
12:12 * daemon started successfully
12:13 Executing tasks: [:app:assembleDebug]
12:16 Emulator: emulator: ERROR: Missing initial data partition file: C:\Users\e1blue\.android\avd\Nexus_5X_API_27_x86.avd/userdata.img
12:16 Emulator: Warning: Quick Boot / Snapshots not supported on this machine. A CPU with EPT + UG features is currently needed. We will address this in a future release.
12:16 Emulator: audio: Failed to create voice `goldfish_audio_in'
12:16 Emulator: qemu-system-x86_64.exe: warning: opening audio input failed
12:16 Emulator: audio: Failed to create voice `adc'
エミュレータが起動され、作成した「POC App」アプリが表示された
Android Studio3 Emulatorでアプリを動かそう