1

i am trying to edit simple Andorid app Build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.51'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

ext{
    support_version = '27.1.1'
    constraint_version = '1.1.2'
    multidex_version = '1.0.3'
    crashlytics_version = '2.9.4'
    rxandroid_version = '2.0.2'
    rxjava_version = '2.1.16'
    rxkotlin_version = '2.2.0'
    databinding_version = '3.1.3'
    viewmodel_version = '1.1.1'
    picasso_version = '2.71828'
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I should add this https://developer.android.com/studio/build/application-id

Where should I place andorid {...}?

MikiBelavista
  • 2,470
  • 10
  • 48
  • 70
  • 1
    [Don't confuse](https://stackoverflow.com/questions/23241681/why-are-there-two-build-gradle-files-in-an-android-studio-project/23241888#23241888) the `build.gradle` at root level and the `app/build.gradle`. The `android` block is used in the `app/build.gradle` – Gabriele Mariotti Apr 29 '21 at 14:11

2 Answers2

1

The top-level build.gradle file, located in the root project directory, defines build configurations that apply to all modules in your project.

The module-level build.gradle file, located in each project/module/ directory, allows you to configure build settings for the specific module it is located in.

According to your requirement, You must use your module level build.grale.

defaultConfig {
        applicationId "com.app.test"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

For better information read official guideline about BUILD.

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

There are 2 gradles, one is called build.gradle (Project:ExampleProject) and the other is build.gradle (Module:app). Put your config in the first one.

Should look like that example:

android {
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    ...
}

PS: As Gabriele Mariotti mentioned before, but this answer is made for more clarity to new users. Cheers :)

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33