How I Can Build Java Module First Then The Rest Of My Android Application?
Solution 1:
In your case the settings_fetcher is a dependency to your app assuming that the settings_fetcher is created as java-library then you can do the following:
In the build.gradle located in app folder place the settings_fetcher project as dependency:
// rest of build.gradle goes here
dependencies{
// Your app's dependencies goes here
implementation project(":settings_fetcher")
}
So once you run ./gradlew build the jar file for your library will be located upon ./settings_fetcher/build/libs folder. Therefore, there's no need for makeJar task as well.
Library Dependencies
Also, any library dependencies should be placed in its own respective build.gradle in your case the one located in settings_fetcher folder in a dependencies section.
For example if your library needs the okHttp client then use:
dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
}
Also in order to use 3rd party libraries ensure that you also have the appropriate repositories as well for example a common repository is the jcenter one:
repositories {
jcenter()
}
Final build.gradle located in settings_fetcher folder
As a result, the final build.gradle will be this one if no extra libraries needed:
plugins {
id'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
Or in case you will need some extra dependencies & libraries:
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_7targetCompatibility= JavaVersion.VERSION_1_7
}
dependencies {
// App dependencies go here.
}
Post a Comment for "How I Can Build Java Module First Then The Rest Of My Android Application?"