20 Kasım 2017 Pazartesi

build.gradle (project) Dosyası

apply plugin
Android uygulamasında şöyle yaparız.
apply plugin: 'com.android.application'
Module için şöyle yaparız.
apply plugin: 'com.android.library'
buildScript/dependencies
Android için kullanılacak Gradle Plugin'i belirtmek için şöyle yaparız.
buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
  }
}
buildScript/dependencies/api
Açıklaması şöyle
When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time. This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library  modules. That's because, if an api dependency changes its external  API, Gradle recompiles all modules that have access to that dependency  at compile time
Şöyle yaparız
api 'com.google.android.support:wearable:2.1.0'
buildScript/dependencies/compile
Bu seçenek deprecate edildi. Onun yerine api kullanılması öneriliyor. Şöyle yaparız
dependencies {

  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile project(':lpd')
  compile 'com.google.android.support:wearable:2.0.0-alpha2'
  compile 'com.google.android.gms:play-services-wearable:9.4.0'
  compile files('libs/zxing_2.3.0.jar')
  compile(name: 'hwwearableservice-release', ext: 'aar')
  compile 'com.google.android.gms:play-services-appindexing:9.4.0'
}
buildScript/dependencies/implementation
Açıklaması şöyle
if an implementation dependency changes its API, Gradle recompiles only that dependency and the modules that directly depend on it. Most app and test modules should use this configuration.
Şöyle yaparız
implementation 'com.google.android.support:wearable:2.1.0'
android/compileSdkVersion seçeneği
Açıklaması şöyle
compileSdkVersion is the API version of Android that you compile against.
buildToolsVersion is the version of the compilers (aapt, dx, renderscript compiler, etc...) that you want to use. For each API level (starting with 18), there is a matching .0.0 version.
Şöyle yaparız
android {
  compileSdkVersion 26
  buildToolsVersion "26.0.2"

  defaultConfig {
    applicationId "com.example.myapplication2_gradle26_3.app"
    minSdkVersion 14
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
  }
  buildTypes {
    release {
      runProguard false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}
android/defaultConfig/minSdkVersion seçeneği
Açıklaması şöyle
minSdkVersion and Minimum API Level refers the same thing. If you are specifying the minSdkVersion as 21, the app will not get installed on the device with API level below 21.
Şöyle yaparız.
defaultConfig {
  applicationId "com.example.ayech0x2.navigationbarforallactivitites"
  minSdkVersion 21
  targetSdkVersion 26
  versionCode 1
  versionName "1.0"
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies
Örnek
Maven'dan indirilecek jar'ları belirtmek için şöyle yaparız
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
}
Örnek
İsmi core olan başka bir modul'e bağımlılığı belirtmek için şöyle yaparız.
dependencies {
  implementation project(':core')
  ...
}
repositories
Şöyle yaparız.
repositories {
  jcenter()
  maven{
    url "https://maven.google.com"
  }
}

Hiç yorum yok:

Yorum Gönder