Skip to content

Commit ba5ee3e

Browse files
author
Adrián García
authored
Fix import libraries (#2)
* Fix import issues with api instead of implementation when importing play-core libs. Add automatic version name via Git tags and refactor versions
1 parent 8ca8b11 commit ba5ee3e

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

app/build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ apply plugin: 'com.android.application'
1919
apply plugin: 'kotlin-android'
2020
apply plugin: 'kotlin-android-extensions'
2121

22+
apply plugin: 'com.gladed.androidgitversion'
23+
2224
android {
23-
compileSdkVersion 29
25+
compileSdkVersion project.ext.compileSdkVersion
26+
2427
defaultConfig {
2528
applicationId "com.bq.appupdateshelper" // Fake, replace with your own
26-
minSdkVersion 21
27-
targetSdkVersion 29
29+
minSdkVersion project.ext.minSdkVersion
30+
targetSdkVersion project.ext.targetSdkVersion
2831
versionCode 1
29-
versionName "1.0.0"
32+
versionName androidGitVersion.name()
3033
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3134
}
3235
buildTypes {
@@ -45,7 +48,7 @@ dependencies {
4548
implementation project(":lib")
4649
implementation fileTree(dir: 'libs', include: ['*.jar'])
4750

48-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
4952

5053
implementation 'androidx.appcompat:appcompat:1.0.2'
5154
implementation 'androidx.core:core-ktx:1.0.2'

build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818

1919
buildscript {
20-
ext.kotlin_version = '1.3.31'
20+
ext.kotlinVersion = '1.3.40'
21+
2122
repositories {
2223
google()
2324
jcenter()
24-
25+
maven { url "https://plugins.gradle.org/m2/" }
2526
}
2627
dependencies {
2728
classpath 'com.android.tools.build:gradle:3.4.1'
28-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
29-
classpath "com.github.dcendents:android-maven-gradle-plugin:2.0"
29+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
30+
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
31+
classpath "com.gladed.androidgitversion:gradle-android-git-version:0.4.9"
3032

3133
// NOTE: Do not place your application dependencies here; they belong
3234
// in the individual module build.gradle files
@@ -37,7 +39,12 @@ allprojects {
3739
repositories {
3840
google()
3941
jcenter()
40-
42+
}
43+
44+
ext {
45+
compileSdkVersion = 29
46+
minSdkVersion = 21
47+
targetSdkVersion = 29
4148
}
4249
}
4350

lib/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
apply plugin: 'com.android.library'
22

3-
android {
4-
compileSdkVersion 29
3+
apply plugin: 'com.gladed.androidgitversion'
54

5+
android {
6+
compileSdkVersion project.ext.compileSdkVersion
67

78
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 29
9+
minSdkVersion project.ext.minSdkVersion
10+
targetSdkVersion project.ext.targetSdkVersion
1011
versionCode 1
11-
versionName "1.0.0"
12+
versionName androidGitVersion.name()
1213

1314
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14-
1515
}
1616

1717
buildTypes {
@@ -25,11 +25,11 @@ android {
2525

2626
dependencies {
2727
implementation fileTree(dir: 'libs', include: ['*.jar'])
28-
implementation "androidx.annotation:annotation:1.1.0"
29-
implementation 'androidx.appcompat:appcompat:1.0.2'
28+
api "androidx.annotation:annotation:1.1.0"
29+
api "androidx.appcompat:appcompat:1.0.2"
3030

3131
// Needed for the in-app updates API
32-
implementation "com.google.android.play:core:1.6.1"
32+
api "com.google.android.play:core:1.6.1"
3333

3434
testImplementation 'junit:junit:4.12'
3535

0 commit comments

Comments
 (0)