[JAVA] How to set BuildConfig of library project (module) to Debug

Summary of this article

During development, you may want to modularize the code you want to use in multiple projects as a library project.

I thought that if the build setting of the main project was debugged, the library project would also be debugged. The library project build settings are always release builds by default.

With this, it is not possible to properly use the processing using BuildConfig in the library project. This time, I will introduce how to match the library project to the project settings of the main unit.

Project configuration example

Suppose you have the following project structure.

・ App // Main project ・ Module // Library project

settings.gradle


include ':app', ':module'

build.gradle(app)


//com.android.Recognized as the main project by specifying application
apply plugin: 'com.android.application' 
--Abbreviation--

dependencies {
・
・
・
    compile project(':module')
・
・
・
}

build.gradle(module)


//com.android.Recognized as a library project by specifying library
apply plugin: 'com.android.library'

The above is the setting when nothing is done.

change point

First, build.gradle of module. Describe publishNonDefault (true).

build.gradle(module)


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    publishNonDefault(true)← Add this
・
・
・
}

Next, app build.gradle Delete the existing complie project (': module') and change as follows.

build.gradle(app)


dependencies {
・
・
・
    debugCompile project(path: ':module', configuration: ':debug')
    releaseCompile project(path: ':module', configuration: ':release')
・
・
・
}

If you do this, the build settings of the module will switch according to the project of the main unit.

Recommended Posts

How to set BuildConfig of library project (module) to Debug
[Rails] Introduction of pry-rails ~ How to debug binding.pry
Set the source of the library set as a dependency in IntelliJ as a separate module of the project
How to set Docker nginx
How to set Java constants
How to set the IP address and host name of CentOS8
How to set Spring Boot + PostgreSQL
How to use setDefaultCloseOperation () of JFrame
How to insert an external library
How to make a Maven project
How to set Lombok in Eclipse
java Eclipse How to debug javaScript
Define a task to ZIP archive a set of project files in Gradle
How to name variables 7 selections of discomfort
[java] Summary of how to handle char
How to remote debug Java 9 or later
How to determine the number of parallels
How to set up and use kapt
How to set JAVA_HOME with Maven appassembler-maven-plugin
[Java] [Maven3] Summary of how to use Maven3
How to sort the List of SelectItem
How to publish a library in jCenter
Needed for iOS 14? How to set NSUserTrackingUsageDescription
[For beginners] How to debug in Eclipse
Let's refer to C ++ in the module of AndroidStudio other project (Java / kotlin)
How to set environment variables in the properties file of Spring boot application
Summary of how to select elements in Selenium
JDBC promises and examples of how to write
How to find the cause of the Ruby error
How to use the camera module OV7725 (ESP32-WROVER-B)
Summary of how to create JSF self-made tags
Customize how to divide the contents of Recyclerview
[Bcrypt] how to cancel presence: true of has_secure_password
[Java] Summary of how to abbreviate lambda expressions
How to get today's day of the week
Output of how to use the slice method
[Java] (for MacOS) How to set the classpath
How to set up and operate jEnv (Mac)
How to use enum (introduction of Japanese notation)
[1st] How to create a Spring-MVC framework project
[Swift UI] How to disable ScrollsToTop of ScrollView
How to set up JavaED Full Edition (pleiades)
How to use JQuery in js.erb of Rails6
How to display the result of form input
[Java] How to get the authority of the folder
How to specify index of JavaScript for statement
Spring Boot --How to set session timeout time
How to set the log level to be displayed in the release version of orhanobut / logger
How to set the retry limit of sidekiq and notify dead queues with slack
Summary of how to use the proxy set in IE when connecting with Java