Peri Hartman
Peri Hartman

Reputation: 19474

android studio: how to regenerate build.gradle

Is there way to have android studio automatically rebuild build.gradle?

I have a case where the compileSdkVersion is wrong (says 18, should be 22). I changed it in the AndroidManifest.xml file but that change did not propagate to the build file. I tried build-clean project, build-rebuild project to no avail.

Obviously I can change it by hand but I would prefer to see a solution that is more automatic and less prone to errors I might unwittingly introduce.

Upvotes: 0

Views: 2889

Answers (1)

Sharjeel
Sharjeel

Reputation: 15798

From the official Android page: http://developer.android.com/tools/building/configuring-gradle.html

The defaultConfig element configures core settings and entries in the manifest file (AndroidManifest.xml) dynamically from the build system.

The values in defaultConfig override those in the manifest file. The configuration specified in the defaultConfig element applies to all build variants, unless the configuration for a build variant overrides some of these values.

You should provide sdk version only in gradle.build file once. If you provide any sdk settings in AndroidManifest.xml it will be overridden by build system with the values in your gradle.build file.

If you create a new project in your latest Android Studio you will notice that Android doesn't put any API version related settings in manifest file anymore. They all go to gradle.build file.

Upvotes: 1

Related Questions