Skip to content

Commit 439f362

Browse files
Update version of Gradle and libraries (#29)
## Description This PR aims to upgrade the gradle version, and also the libraries used in the project. The table below shows the upgrades: | Artifact | Old version | New version | | --------- | -------------- | ---------------- | | Gradle | `6.7.1` | `7.5` | | Kotlin | `1.5.31` | `1.9.10` | | Android SDK | `30` | `33` | | android-gradle-plugin | `4.2.2` | `7.4.2` | | appcompat | `1.3.1` | `1.6.1` | | constraintlayout | `2.1.2` | `2.1.4` | | junit | `1.1.3` | `1.1.5` | | espresso-core | `3.4.0` | `3.5.1` | ### View Binding changes In this new version of the Android SDK, Kotlin Android Extensions are deprecated, which means that using Kotlin synthetics for view binding is no longer supported. How the project used Kotlin synthetics for view binding, this [guide](https://developer.android.com/topic/libraries/view-binding/migration) was used to migrate to Jetpack view binding. For this it was necessary: - Set the `viewBinding` build option to `true` in the module-level `build.gradle` file: ``` android { ... buildFeatures { viewBinding = true } } ``` - Inflate the generated binding class instance for the activity to use (guide [here](https://developer.android.com/topic/libraries/view-binding#activities)): To set up an instance of the binding class for use with an activity, perform the following steps in the activity's `onCreate() `method: 1. Call the static inflate() method included in the generated binding class. This creates an instance of the binding class for the activity to use. 2. Get a reference to the root view by either calling the `getRoot()` method or using Kotlin property syntax. 3. Pass the root view to `setContentView()` to make it the active view on the screen. These steps resulted in the following code: ``` ... private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) } ... ```
1 parent eff7b82 commit 439f362

7 files changed

Lines changed: 26 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ captures/
5555
/build
5656
/captures
5757
.externalNativeBuild
58+
core/.cxx/

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.5.31'
4+
ext.kotlin_version = '1.9.10'
55
repositories {
66
google()
77
mavenCentral()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.2.2'
10+
classpath 'com.android.tools.build:gradle:7.4.2'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

core/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
android {
6-
compileSdkVersion 30
5+
compileSdkVersion 33
76
buildToolsVersion "30.0.3"
87

98
defaultConfig {
109
minSdkVersion 21
11-
targetSdkVersion 30
10+
targetSdkVersion 33
1211
versionCode 3
1312
versionName "0.2.9"
1413
externalNativeBuild {

demo/build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
android {
6-
compileSdkVersion 30
5+
compileSdkVersion 33
76
buildToolsVersion "30.0.3"
87

98
defaultConfig {
109
applicationId "br.com.nvsistemas.parsec.demo"
1110
minSdkVersion 21
12-
targetSdkVersion 30
11+
targetSdkVersion 33
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -24,18 +23,22 @@ android {
2423
}
2524
}
2625

26+
viewBinding {
27+
enabled = true
28+
}
29+
2730
}
2831

2932
dependencies {
3033
implementation fileTree(dir: 'libs', include: ['*.jar'])
3134
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
32-
implementation 'androidx.appcompat:appcompat:1.3.1'
33-
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
35+
implementation 'androidx.appcompat:appcompat:1.6.1'
36+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
3437

3538
testImplementation 'junit:junit:4.13.2'
3639

37-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
38-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
40+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
3942

4043
implementation project(path: ':core')
4144
}

demo/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
android:allowBackup="true"
77
android:supportsRtl="true"
88
android:theme="@style/AppTheme">
9-
<activity android:name=".MainActivity">
9+
<activity android:name=".MainActivity"
10+
android:exported="true">
1011
<intent-filter>
1112
<action android:name="android.intent.action.MAIN" />
1213

demo/src/main/java/br/com/nvsistemas/parsec/demo/MainActivity.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,24 @@ package br.com.nvsistemas.parsec.demo
33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
55
import br.com.nvsistemas.parsec.Parsec
6-
import kotlinx.android.synthetic.main.activity_main.expression
7-
import kotlinx.android.synthetic.main.activity_main.expression2
8-
import kotlinx.android.synthetic.main.activity_main.result
9-
import kotlinx.android.synthetic.main.activity_main.result2
10-
import kotlinx.android.synthetic.main.activity_main.show_result_btn
11-
import kotlinx.android.synthetic.main.activity_main.show_result_btn2
6+
import br.com.nvsistemas.parsec.demo.databinding.ActivityMainBinding
127

138
class MainActivity : AppCompatActivity() {
149

1510
private val parsec = Parsec()
11+
private lateinit var binding: ActivityMainBinding
1612

1713
override fun onCreate(savedInstanceState: Bundle?) {
1814
super.onCreate(savedInstanceState)
19-
setContentView(R.layout.activity_main)
15+
binding = ActivityMainBinding.inflate(layoutInflater)
16+
setContentView(binding.root)
2017

21-
show_result_btn.setOnClickListener {
22-
result.text = eval(expression.text.toString())
18+
binding.showResultBtn.setOnClickListener {
19+
binding.result.text = eval(binding.expression.text.toString())
2320
}
2421

25-
show_result_btn2.setOnClickListener {
26-
result2.text = eval(expression2.text.split(",").map { it.trim() })
22+
binding.showResultBtn2.setOnClickListener {
23+
binding.result2.text = eval(binding.expression2.text.split(",").map { it.trim() })
2724
}
2825
}
2926

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Nov 17 15:17:34 BRT 2021
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)