Upgrade to Pro — share decks privately, control downloads, hide ads and more …

少し幸せにする技術

kamedon
March 09, 2017

 少し幸せにする技術

DroidKaigi 2017 3/9 Room4 18:00~
Kamedon

リンクが有効なバージョン
https://www.slideshare.net/kamedon39/ss-72985127

kamedon

March 09, 2017
Tweet

More Decks by kamedon

Other Decks in Technology

Transcript

  1. ଞͷIDEͱγϣʔτΧοτ͕
 ҧ͏ͷͰɺΠϥΠϥ͖ͯͨ͠ • Android Studio ࠷ڧίϚϯυ
 Find Action • Mac:

    ⌘ ⇧ A • Windows: Ctrl Shift A
 • ίϚϯυΛݕࡧͰ͖ɺγϣʔτΧοτ·ͰΘ͔Δ • ઃఆͰKeymapΛมߋ͢Δͱ޷ΈͷઃఆʹͰ͖Δ
  2. ςετͰ௨ͬͯͳ͍ͱ͜ΖΛ஌ Γ͍ͨ public class CalcUtil {
 public static int mod(int

    x, int y) {
 if (y == 0) {
 throw new IllegalArgumentException("y != 0");
 }
 return x % y;
 }
 }
  3. public class CalcUtilTest {
 
 @Test
 public void 余りのテスト() {

    
 Assert.assertThat(3,Is.is(CalcUtil.mod(11, 4)));
 }
 } ςετͰ௨ͬͯͳ͍ͱ͜ΖΛ஌ Γ͍ͨ Z͕ͷέʔε͕ൈ͚͍ͯΔ
  4. όʔδϣϯίʔυͱόʔδϣϯ ໊؅ཧ͕ΊΜͲ͍͘͞ buildTypes {
 release {}
 debug {
 applicationIdSuffix ".debug"


    }
 }
 productFlavors {
 demo {
 applicationIdSuffix ".demo"
 }
 full {
 applicationIdSuffix ".full"
 }
 } ϓϩμΫτϑϨʔόʔ ϏϧυόϦΞϯτ BQQCVJMEHSBEMF \QLH^\'MBWPS^\#VJME5ZQF^ \QLH^EFNPEFCVH
  5. buildTypes {
 release {
 buildConfigField "String", "ENDPOINT", "\"https://hoge.com\" "
 }


    debug {
 applicationIdSuffix ".debug"
 buildConfigField "String", "ENDPOINT", "\"https://localhost\" "
 }
 }
 
 productFlavors {
 demo {
 buildConfigField "boolean", "DEMO", "true"
 applicationIdSuffix ".demo"
 }
 full {
 buildConfigField "boolean", "DEMO", "false"
 applicationIdSuffix ".full"
 }
 } ։ൃͱ੡඼൛Ͱఆ਺Λ෼͚͍ͨ
  6. buildTypes {
 release {
 buildConfigField "String", "ENDPOINT", "\"https://hoge.com\" "
 }


    debug {
 applicationIdSuffix ".debug"
 buildConfigField "String", "ENDPOINT", "\"https://localhost\" "
 }
 }
 
 productFlavors {
 demo {
 buildConfigField "boolean", "DEMO", "true"
 applicationIdSuffix ".demo"
 }
 full {
 buildConfigField "boolean", "DEMO", "false"
 applicationIdSuffix ".full"
 }
 } ։ൃͱ੡඼൛Ͱఆ਺Λ෼͚͍ͨ
  7. όʔδϣϯίʔυͱόʔδϣϯ ໊؅ཧ͕ΊΜͲ͍͘͞ def major = 1
 def minor = 0


    def patch = 0
 def build = 0
 
 android {
 defaultConfig {
 versionCode major * 10000 + minor * 1000 + patch * 100 + build
 versionName "${major}.${minor}.${patch}"
 }
 } WFSTJPO/BNFͱWFSTJPO$PEF
 Λ࿈ಈ͢ΔΑ͏ʹ͢Δ ։ൃऀ͸WFSTJPO/BNFΛ্͍͛ͨ (PPHMF1MBZ͸ɺWFSTJPO$PEF্͕͕ͬͯΕ͹Α͍
  8. ॺ໊৘ใΛϑΝΠϧʹॻ͖ग़͢ • build.gradleͰಡΉ͜Ή signingConfigs {
 debug {
 def keystorePropertiesFile =

    rootProject.file("keystore.properties")
 def keystoreProperties = new Properties()
 keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) 
 keyAlias keystoreProperties['keyAlias']
 keyPassword keystoreProperties['keyPassword']
 storeFile file(keystoreProperties['storeFile'])
 storePassword keystoreProperties['storePassword']
 }
 }
  9. Logͷ͍ͤͰUnit TestͰΤϥʔ ͕ͰΔ • Log͚ͩͳΒɺClassLoaderͷ࢓૊ΈΛ࢖ͬͯLogΛ্ॻ͖͢Δ
 app/src/test/java/android/util/Log.javaʹҎԼΛஔ͘ public class Log {


    public static int v(String tag, String msg) { return 0; }
 public static int v(String tag, String msg, Throwable tr) { return 0; }
 public static int d(String tag, String msg) { return 0; }
 public static int d(String tag, String msg, Throwable tr) { return 0; }
 public static int i(String tag, String msg) { return 0; }
 public static int i(String tag, String msg, Throwable tr) { return 0; }
 public static int w(String tag, String msg) { return 0; }
 public static int w(String tag, String msg, Throwable tr) { return 0; }
 public static int w(String tag, Throwable tr) { return 0; }
 public static int e(String tag, String msg) { return 0; }
 public static int e(String tag, String msg, Throwable tr) { return 0; }
 }
  10. ProGuard • ηΩϡϦςΟతʹ࠷௿ݶϦϦʔε࣌ʹඞͣઃ ఆ͢Δ • ΞϓϦαΠζͷ࡟ݮ • ؾٳΊ೉ಡԽ public class

    MainActivity extends c {
 private TextView m;
 public MainActivity() {}
 protected void onCreate(Bundle var1) {
 super.onCreate(var1);
 this.setContentView(2130968603);
 this.m = (TextView)this.findViewById(2131427415);
 this.m.setText("hello world");
 }
 }
  11. ϦϦʔεͷͱ͖͚ͩProGuard ͔͚ΔͱυΩυΩ͢Δ • ։ൃதʹ΋ProGuardΛ͔͚Δͱ҆৺ • Ϗϧυ͕஗͘ͳΔͷ͕ܽ఺ • ։ൃ࣌͸ɺίʔυ࡟ݮ͸͢Δ͕ɺϦωʔϜ͸͠ͳ͍΄͏͕ Α͍ buildTypes

    {
 debug {
 minifyEnabled true
 useProguard false
 proguardFiles getDefaultProguardFile('proguard- android.txt'),
 'proguard-rules.pro'
 }
 }
  12. ·ͱΊ • Android Studio…ૉఢͰ͢ • Build.gradleपΓΛௐ΂Δͱ։ൃָ͕ʹͳΔ • σόοάπʔϧ΋๛෋ʹͳ͖ͬͯͨ • Google

    Play Console͸࠷ۙػೳ͕૿͑ͨͷͰɺ֬ೝ • ୺຤ґଘ͸͕Μ͹Δ • ProGuard͸ఆظతʹ͔͚࣮ͯߦ͢Δͱ҆৺