How to create a new Build.Radle?

Asked

Viewed 1,412 times

4

Since I imported my project from github, I’m trying this error:

Migrate Project to Gradle? This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system

A guy already told me I need to create a build.Radle to add to the project, but I don’t know how to do it. someone can help me?

  • Your project came from the eclipse?

  • No, it came from android studio same

  • @Caiqueoliveira My project came from Eclipse. In case you know how to do you could help me ?

  • @Victorhenrique vc should download the project and import it in android studio through the option: import project (Eclipse ADT, Gradle,etc.)

1 answer

1

TL;DR

The message is recommendation, not obligation, but worth using Gradle in the project.

Gradle

Gradle is an automation tool for build, that is, of the processes involving your code for compilation, packaging, testing and distribution.

A project using Gradle must have at least one file build.gradle with the necessary settings.

Ides as Eclipse and Intellij, the latter the basis of the Android Studio, make use of the Gradle configuration to perform some automatic settings, although it is perfectly possible to perform these settings manually, that is, without Gradle.

Gradle is usually recommended for Android development rather than manual configuration, as it greatly facilitates development and standardizes procedures for compiling and distributing the project.

Example of simple configuration

To documentation gives an example of a simple configuration for an Android project:

buildscript {
    repositories { 
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.1.0'
}

Build Init Plugin

For some common project types, there is a Gradle plugin that lets you generate the basic configuration: Build Init Plugin. For example, if you have Gradle installed you can run the following command line:

gradle init --type java-library

Basic configuration will be created according to type (type) design. However, this plugin is still in the incubation process and still has no option for an Android project. In addition, the configuration is basic and probably more specific changes will be needed.

Of course, each project can have different settings and you’ll probably need to go through the documentation to get all the details.

Considerations

Build automation is something that can give a headache at first, especially the first time it is done, but it is something that is paid with time.

At this point, a few times you can rely on Ides or tools to generate a basic configuration, but I don’t recommend depending on it or always follow this path. It’s best to spend a little time understanding the basics of how Gradle works.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.