Android Studio完全移行ガイド

Similar documents
Vuzix M100 SDKインストールガイド

「Android Studioではじめる 簡単Androidアプリ開発」正誤表

Microsoft Word - jpluginmanual.doc

untitled

Android Studioセットアップガイド

MINI2440マニュアル

Introduction Purpose This training course describes the configuration and session features of the High-performance Embedded Workshop (HEW), a key tool

Quickstart Guide 3rd Edition

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

1: Android 2 Android 2.1 Android 4 Activity Android Service ContentProvider BroadcastReceiver Activity ( ): Android 1 Android Service ( ): ContentProv

1: Preference Display 1 package sample. pref ; 2 3 import android. app. Activity ; 4 import android. content. Intent ; 5 import android. content. Shar


K227 Java 2

Java演習(4) -- 変数と型 --

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

: : : TSTank 2


cocos2d-x #cocos2d-x

,,,,., C Java,,.,,.,., ,,.,, i

Prog2_6th

Java updated

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

Oracle Lite Tutorial

fx-9860G Manager PLUS_J

Configuring_01

untitled

新・明解Java入門

展開とプロビジョニングの概念

Microsoft Word - D JP.docx


atmark-dist ディベロッパーズガイド

untitled

Effective Android NDK Advanced Core Engineer

Nios II 簡易チュートリアル

発環境を準備しよう2 章開Eclipseをインストールしようそれでは Eclipseをセットアップしましょう Eclipseは Eclipse Foundationのサイトからダウンロードできます ダウンロードのページを開くと いく

untitled

Smalltalk_

JavaScript の使い方

B1 Ver ( ), SPICE.,,,,. * : student : jikken. [ ] ( TarouOsaka). (, ) 1 SPICE ( SPICE. *1 OrCAD

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment

@makoto_anjo (Computer Science) Google Desktop(Hall of Fame)

Nios II ハードウェア・チュートリアル

PowerGres on Linuxマニュアル

1 I EViews View Proc Freeze

<4D F736F F D20566F F6E658C6791D FE382C582CC4A D834F E F8F4390B394C52E646F63>

TopLink È... 3 TopLink...5 TopLink åø... 6 TopLink å Workbench O/R ~... 8 Workbench À ~... 8 Foundation Library å... 8 TopL

MINI2440マニュアル

Cisco ASA Firepower ASA Firepower

ProVAL Recent Projects, ProVAL Online 3 Recent Projects ProVAL Online Show Online Content on the Start Page Page 13

Java Platform Debugger Architecture Apache JServ Oracle JVM JPDA JVM Tomcat Oracle JVM... 7

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir

1 1.1 (JCPRG) 30 Nuclear Reaction Data File (NRDF) PC GSYS2.4 JCPRG GSYS2.4 Java Windows, Linux, Max OS X, FreeBSD GUI PNG, GIF, JPEG X Y GSYS2

help gem gem gem my help

Cleaner XL 1.5 クイックインストールガイド

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

Rによる計量分析:データ解析と可視化 - 第2回 セットアップ

グラフ数値読み取りシステム (GSYS2.4) 利用の手引

About me! 足立昌彦 / +Masahiko.Adachi )! バイドゥ株式会社技術顧問 (Simeji)! 株式会社カブク Co-Founder! Google Developer Expert (Android)

Emacs Ruby..

第173回東京エリアDebian勉強会   grml-debootstrapを用いた USB起動メモリの作成

Transcription:

Android Studio 2016/01/04 1

Android Studio Android Studio ADT 1 Android Studio ADT Android Studio Google I/O 2013 Android IDE JetBrains IntelliJ IDEA *1 ADT Android Developer Tools 2007 Android Eclipse IDE Eclipse Eclipse Time to Migrate 2015 1 Android Studio 1.0 Android Studio ADT Google 2015 ADT An update on Eclipse Android Developer Tools http://android-developers.blogspot.jp/2015/06/an-update-on-eclipse-android-developer.html AS Android ADT ADT Android Studio Migrate IDE ADT Ant ADT Android Studio 1 Ant Android Studio(Gradle) *1 IntelliJ IDEA Community Edition 2

2 Android Studio ADT Eclipse Mars 1. Release (4.5.1) ADT plugin 23.0.7 Android Studio 1.5.1 Android NDK r10e Android Studio PDF http://keiji.github.io/farewell-adt-book/archives/farewell-adt.pdf GitHub https://github.com/keiji/farewell-adt-book 3

c R TM 4.0 - *2 Creative Commons License The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution license. The Android Studio icon is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 2.5 Attribution license. The Icon for Android ADT bundle is reproduced or modified from work created and shared by Android Developers and used according to terms described in the Creative Commons 3.0 Attribution license. *2 http://creativecommons.org/licenses/by-nc-nd/4.0/deed.ja 4

2 Time to Migrate............................................... 2.......................................... 3................................................ 3 4.................................................... 4............................................... 4................................................ 4 Creative Commons License......................................... 4 1 Android Studio 7 1.1 ADT........................... 7 1.2....................................... 7 1.2.1............................... 8 1.3....................................... 10 1.3.1................................... 10 1.3.2...................................... 13 1.3.3...................................... 15 1.3.4....................................... 16 1.3.5....................................... 16 1.3.6 Java.................................. 16 1.3.7..................................... 17 1.3.8 AndroidManifest.xml................................ 18 1.3.9 NDK......................................... 19 2 Gradle Cookbook 23 2.1................... 23 2.1.1 Product Flavor................................. 23 2.1.2..................................... 24 2.1.3.................................... 26 2.2......................... 27 2.2.1 applicationidsuffix versionnamesuffix......................... 27 2.2.2 ApplicationId.................................... 28 2.2.3 versioncode versionname.......................... 28 2.2.4 AndroidManifest.xml............................... 29 2.3........................... 30 2.4 Build Type.................................. 30 5

2.5................................ 31 2.6 Lint........................ 32 2.7................. 32 Android Studio Android 34 6

1 Android Studio ADT Android Studio 1.1 ADT Android Studio ADT 1.1 Import Project(Eclipse ADT, Gradle etc.) ADT Android Studio ADT ADT Android Studio Android Studio ADT 1.2 ADT Android Studio 7

1 Android Studio farewelladt_workspace 1.1 1.1: ADT. -- FarewellAdt -- AndroidManifest.xml -- assets -- bin -- jni -- libs -- obj -- proguard-project.txt -- project.properties -- res -- src -- library -- AndroidManifest.xml -- assets -- bin -- libs -- proguard-project.txt -- project.properties -- res -- src 1.2.1 ADT 1.1 1.1 API Level API Level Project Build Target NDK ADT ADT AndroidManifest.xml package AndroidManifest.xml versioncode AndroidManifest.xml versionname AndroidManifest.xml minsdkversion AndroidManifest.xml targetsdkversion libs jni ADT Properties Project Properties Android 1.2 8

1.2 1.2 Project Build Target Library Project Build Target Android API Level Library is library Reference farewelladt_workspace 2 FarewellAdt library 1.2 FarewellAdt FarewellAdt io.keiji.farewelladt 1 1.0 API Level 15 API Level 23 Project Build Target Android 6.0 - API Level 23 false library android-support-v4.jar NDK 9

1 Android Studio 1.3 library library io.keiji.library 1 1.0 API Level 8 API Level 21 Project Build Target Android 6.0 - API Level 23 true android-support-v4.jar NDK 1.3 1. Android Studio 2. 3. 4. 5. 6. 7. 8. AndroidManifest.xml 9. NDK JNI 1.3.1 Android StudioFarewellAdt Start a new Android Studio project Company Domain Package name Application name Company Domain Package name 10

1.3 Company DomainADT Package name Edit Package name API Level minsdkversion Android 4.0.3 (Ice Cream Sandwich) Activity ADT Activity Add no ActivityFinish Android Studio 11

1 Android Studio Android Studio ADT Android Studio ADT Eclipse Android Studio IntelliJ IDEA Project View Android Studio Android View Android View Project View 12

1.3 1.3 Project Project Files 1.3.2 ADT library File New New Module ADT library Android Library ADT Phone and Tablet Application/Library name *1 API Level minsdkversion ADT library Android 2.2 (Froyo) *1 Application/Library name ADT 13

1 Android Studio Finish Android Studio library dependencies Android Studio FarewellAdt library 2 FarewellAdt library FarewellAdt library build.gradle FarewellAdt app/build.gradle 1.2 dependencies compile project( :library ) 1.2: library dependencies apply plugin: com.android.application android {... dependencies {... compile project( :library ) Gradle Android Studio Gradle build.gradle Gradle 14

1.3 : Gradlephant ADT Eclipse APK Application PacKage CI Continuous Integration android Ant ADT Ant Ant ADT ADT Gradle Android Studio ADT Ant Gradle ADT Android Studio 1.3.3 ADT FarewellAdt library android-support-v4.jar libs Android Studio FarewellAdt library build.gradle dependencies appcompat-v7 1.3 appcompat-v7 android-support-v4 *2 1.3: appcompat-v7 dependencies { compile filetree(dir: libs, include: [ *.jar ])... compile com.android.support:appcompat-v7:23.1.1... Android Studio Gradle jar libs dependencies Gradle Maven *2 Gradle appcompat-v7 android-support-v4 15

1 Android Studio Cnetral *3 jcenter *4 ButterKnife ADT ButterKnife jar libs Android Studio Gradle dependencies ButterKnife 1.4 jar libs 1.4: ButterKnife dependencies dependencies { compile filetree(dir: libs, include: [ *.jar ])... compile com.jakewharton:butterknife:7.0.1 1.3.4 ADT res Android Studio src/main/res drawable mipmap ADT res/drawable-* Android Studio src/main/res/mipmap-* mipmap 3D res/drawable-* PNG src/main/res/mipmap-* R.mipmap.* @mipmap/* drawable mipmap ADT src/main/res/mipmap-* src/main/androidmanifest.xml @drawable/ic_launcher @mipmap/ic_launcher 1.3.5 ADT assets Android Studio src/main/assets 1.3.6 Java ADT Java src Android Studio src/main/java *3 Maven Central: http://search.maven.org/ *4 jcenter: https://bintray.com/bintray/jcenter 16

1.3 ADT & OS X Finder 1.3.7 ADT Android Studio src/androidtest/java Android Studio ADT & OS X Finder build.gradle build.gradle testinstrumentationrunner dependencies com.android.support.test:support-annotations com.android.support.test:runner 1.5: testinstrumentationrunner dependencies apply plugin: com.android.application android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" er" // testinstrumentationrunner "android.support.test.runner.androidjunitrunn\ buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro dependencies { compile filetree(include: [ *.jar ], dir: libs ) testcompile junit:junit:4.12 compile com.android.support:appcompat-v7:23.1.1 compile project( :library ) androidtestcompile com.android.support:support-annotations:23.1.1 androidtestcompile com.android.support.test:runner:0.3 17

1 Android Studio 1.3.8 AndroidManifest.xml ADT AndroidManifest.xml Android Studio src/main/ AndroidManifest.xml build.gradle Android Studio ADT AndroidManifest.xml build.gradle build.gradle 1.4 1.4 build.gradle compilesdkversion minsdkversion targetsdkversion versioncode versionname AndroidManifest.xml 1.6 build.gradle 1.6: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.keiji.farewelladt" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="15" android:targetsdkversion="23" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".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> </manifest> versioncode versionname build.gralde 1.7 1.7: versioncode versionname 18

1.3 apply plugin: com.android.application android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro dependencies { compile filetree(include: [ *.jar ], dir: libs ) testcompile junit:junit:4.12 compile com.android.support:appcompat-v7:23.1.1 compile project( :library ) Android Studio AndroidManifest.xml 1.3.9 NDK NDK Native Development Kit NDK NDK Android Studio NDK Open Module Settings SDK Locations Android NDK Location NDK 19

1 Android Studio 1.4 Android NDK Location ADT jni Android Studio src/main/jni build.gradle build.gradle NDK build.gradle 1.8 NDK experimental Gradle 1.8: build.gradle buildscript { repositories { jcenter() dependencies { classpath "com.android.tools.build:gradle-experimental:0.4.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files allprojects { repositories { jcenter() task clean(type: Delete) { delete rootproject.builddir 20

1.3 gradle-experimental 2015 12 gradle-experimental 0.6.0-alpha2 0.6.0-alpha2 gradle/wrapper/gradle-wrapper.properties gradle-2.9-all.zip FarewellAdt library plugin 1.9 com.android.application com.android.model.application com.android.model.application DSL Domain-Specific Language android model compilesdkversion = defaultconfig.with API Level minsdkversion.apilevel 1.9: NDK DSL apply plugin: com.android.model.application model { android { compilesdkversion = 23 buildtoolsversion = "23.0.2" defaultconfig.with { applicationid = "io.keiji.farewelladt" minsdkversion.apilevel = 15 targetsdkversion.apilevel = 23 versioncode = 1 versionname = "1.0" android.buildtypes { release { minifyenabled = false proguardfiles.add(file("proguard-rules.pro")) android.ndk { modulename = "hello-jni" dependencies { compile filetree(include: [ *.jar ], dir: libs ) compile com.android.support:appcompat-v7:23.1.1 library com.android.model.library 1.10 1.10: apply plugin: com.android.model.library 21

1 Android Studio model { android { compilesdkversion = 23 buildtoolsversion = "23.0.2" defaultconfig.with { minsdkversion.apilevel = 15 targetsdkversion.apilevel = 23 android.buildtypes { release { minifyenabled = false proguardfiles.add(file("proguard-rules.pro")) dependencies { compile filetree(dir: libs, include: [ *.jar ]) compile com.android.support:appcompat-v7:23.1.1 JNI versioncode versionname defaultconfig.with versioncode versionname org.gradle.api.internal.extensibledynamicobject NDK http://tools.android.com/tech-docs/new-build-system/gradle-experimental 22

2 Gradle Cookbook Ant Gradle 2.1 Product Flavors APK trialcommercial 2.1.1 Product Flavor app/src 2 trial commercial flavor commercial trial. -- app.iml -- build -- build.gradle -- libs -- proguard-rules.pro -- src -- androidtest -- commercial -- main -- AndroidManifest.xml -- java.io.keiji.farewelladt -- MainActivity.java -- res -- test -- trial app/build.gradle productflavors 2.1 2.1: productflavors apply plugin: com.android.application android { productflavors { 23

2 Gradle Cookbook trial commercial 2.1.2 flavor. FooBar.java FooBar.java flavor. -- app.iml -- build -- build.gradle -- libs -- proguard-rules.pro -- src -- androidtest -- commercial -- java.io.keiji.farewelladt -- FooBar.java -- main -- AndroidManifest.xml -- java.io.keiji.farewelladt -- MainActivity.java -- res -- test -- trial -- java.io.keiji.farewelladt -- FooBar.java assemble flavor FooBar.java APK main flavor flavor main main flavor main Gradle assemble flavor assembletrial assemblecommercial flavor 24

2.1 2.1 flavor Android Studio Build Variants 2.2 Build Variants Product FlavorsBuild Types 2 2.2 Build Variants - Product Flavor Build Type OS X Finder./gradlew [ ]./gradlew tasks Gradle gradle wrapper 25

2 Gradle Cookbook $./gradlew tasks Starting a new Gradle Daemon for this build (subsequent builds will be faster). Parallel execution is an incubating feature. :tasks ------------------------------------------------------------ All tasks runnable from root project ------------------------------------------------------------ Android tasks ------------- androiddependencies - Displays the Android dependencies of the project. signingreport - Displays the signing info for each variant. sourcesets - Prints out all the source sets defined in this project. Build tasks ----------- assemble - Assembles all variants of all applications and secondary packages. assembleandroidtest - Assembles all the Test applications. assemblecommercial - Assembles all Commercial builds. assembledebug - Assembles all Debug builds. assemblerelease - Assembles all Release builds. assembletrial - Assembles all Trial builds. build - Assembles and tests this project. builddependents - Assembles and tests this project and all projects that depend on it. buildneeded - Assembles and tests this project and all projects it depends on. clean - Deletes the build directory. [ ] BUILD SUCCESSFUL Total time: 8.705 secs 2.1.3 flavor. ic_launcher.png commercial ic_launcher.png commercial flavor. -- app.iml -- build.gradle -- libs -- proguard-rules.pro -- src -- androidtest -- commercial -- res -- mipmap-xxxhdpi -- ic_launcher.png -- main -- AndroidManifest.xml -- java -- res -- drawable -- layout -- mipmap-xxxhdpi -- ic_launcher.png 26

2.2 -- values -- values-w820dp -- test -- trial flavor commercial APK main flavor main flavor flavor main APK 2.2 applicationid, minsdkversion, versioncode, versionname 2.2.1 applicationidsuffix versionnamesuffix 2.2 applicationidsuffix versionnamesuffix applicationidsuffix applicationid versionnamesuffix versionname Suffix applicationid versionname defaultconfig 2.2: debug applicationid.debug android { defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" buildtypes { debug { applicationidsuffix.debug versionnamesuffix debug release { minifyenabled true proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro debug applicationid io.keiji.farewelladt.debug versionname 1.0 debug 27

2 Gradle Cookbook 2.2.2 ApplicationId applicationid 2.3 applicationid 2.3: ApplicationId android { defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" productflavors { trial { commercial { applicationid jp.foo.helloandroidstudio.commercial 2.2.3 versioncode versionname versioncode versionname 2.4 versioncode versionname 2.4: trial commercial versioncode versionname android { defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" productflavors { trial { versioncode 30 commercial { versionname Commercial Version versioncode 10001 28

2.2 2.2.4 AndroidManifest.xml applicationidsuffix applicationid AndroidManifest.xml applicationid ContentProvider authorities 2.3 INSTALL_FAILED_CONFLICTING_PROVIDER AndroidManifest.xml build.gradle applicationid Manifest Merger 2.5 2.5: provider authorities applicationid <?xml version="1.0" encoding="utf-8"?> <manifest package="io.keiji.farewelladt" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" 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> <provider android:name=".provider.somecontentprovider" android:authorities="${applicationid"/> </application> </manifest> {applicationid Biuld Variants applicationid build.gradle AndroidManifest.xml URL Android Tools Project Site - Manifest Merger 29

2 Gradle Cookbook http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger 2.3 2.6 Git Git gitsha git buildtypes debug versionname versionnamesuffix 2.6: gitsha apply plugin: com.android.application def gitsha() { return git rev-parse --short HEAD.execute().text.trim() android { buildtypes { debug { applicationidsuffix.debug versionnamesuffix + gitsha() 2.4 Build Type debug release Buid Type initwith Build Type Build Type 2.7 debug openbeta 2.7: Build Type buildtypes { debug { applicationidsuffix.debug versionnamesuffix + gitsha() openbeta.initwith(buildtypes.debug) openbeta { minifyenabled true proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro openbeta debug versionnamesuffix applicationidsuffix minifyenabled APK 30

2.5 2.5 BuildConfig build.gradle Build Variants 2.8 2.8: buildconfigfield android { defaultconfig { applicationid "io.keiji.farewelladt" minsdkversion 15 targetsdkversion 23 versioncode 1 versionname "1.0" buildconfigfield "String", "API_URL", "\"https://test.keiji.io/\"" buildtypes { release { minifyenabled true proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro buildconfigfield "String", "API_URL","\"https://blog.keiji.io/\"" 2.9 BuildConfig.java release BuildConfig.java 2.9: API_URL /** * Automatically generated file. DO NOT MODIFY */ package io.keiji.farewelladt; public final class BuildConfig { public static final boolean DEBUG = Boolean.parseBoolean("true"); public static final String APPLICATION_ID = "io.keiji.farewelladt.debug"; public static final String BUILD_TYPE = "debug"; public static final String FLAVOR = "trial"; public static final int VERSION_CODE = 30; public static final String VERSION_NAME = "1.0"; // Fields from default config. public static final String API_URL = "https://test.keiji.io/"; 31

2 Gradle Cookbook 2.6 Lint Lint assemblerelease Lint lintoptions Lint APK 2.10 2.10: Lint android { lintoptions { abortonerror false 2.7 build.gradle foo-bar.properties foo-bar.properties.gitignore Git 2.11 2.11: foo-bar.properties storefile=[] storepassword=[ ] keyalias=[ ] keypassword=[ ] build.gradle 2.12 signingconfigs foo-bar.properties Properties 2.12: android { signingconfigs { release { 32

2.7 File propfile = rootproject.file("foo-bar.properties") if (propfile.exists()) { Properties props = new Properties() props.load(new FileInputStream(propFile)) storefile file(props.storefile) storepassword props.storepassword keyalias props.keyalias keypassword props.keypassword buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile( proguard-android.txt ), proguard-rules.pro signingconfig signingconfigs.release 33

Android Studio Android : Android Studio Android Android Android Studio Android Studio 1.5 [ *1 ] Chapter 1 Android Chapter 2 Android Studio Windows Chapter 3 Android Studio OS X Chapter 4 Chapter 5 Hello Android Chapter 6 Web API Chapter 7 Chapter 8 Chapter 9 *1 http://gihyo.jp/book/2016/978-4-7741-7859-2 34

Android Studio 2016 01 04 4.0 35