Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated all dependencies in Pr/40 #47

Open
wants to merge 5 commits into
base: pr/40
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated all dependencies + overall improvements
DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.

Updated gradle to version 7
Replaced maven with maven-publish

Removed kotlin extensions as required and adapted mainActivity code to this

Removed multidex lib as not needed anymore from API 21

WebSocket lib old version was full of security bugs.

For Android projects consisting of an app with library dependencies, it is recommended to set checkDependencies to true
https://developer.android.com/studio/releases/gradle-plugin#improved_lint_for_library_dependencies
  • Loading branch information
mobilekosmos committed Sep 24, 2021
commit 9f0ed4bd6d7882f2a27acc98120e796a433bc12c
72 changes: 35 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
/**
* The buildscript block is where you configure the repositories and
* dependencies for Gradle itself—meaning, you should not include dependencies
* for your modules here. For example, this block includes the Android plugin for
* Gradle as a dependency because it provides the additional instructions Gradle
* needs to build Android app modules.
*/
buildscript {
ext {
versions = [
kotlin : "1.4.31",
moshi : '1.8.0',
okhttp : '3.11.0',
jupiter : '5.7.0',
kotlin : "1.5.31",
moshi : '1.12.0',
okhttp : '4.9.1',
jupiter : '5.8.1',

'minSdk' : 14,
'compileSdk' : 28,
'buildTools' : '28.0.3',
'androidPlugin' : '4.0.0',
'minSdk' : 28,
'compileSdk' : 31,

androidx_app_compat : '1.0.2',
androidx_card_view : '1.0.0',
androidx_constraint_layout: '1.1.3',
androidx_lifecycle : '2.0.0',
androidx_test_ext : '1.1.0',
androidx_recycler_view : '1.0.0',
androidx_room : '2.0.0',

multidex : '2.0.1',
]

ext.deps = [
android: [
'runtime' : 'com.google.android:android:4.1.1.4',
'gradlePlugin': "com.android.tools.build:gradle:${versions.androidPlugin}",
]
androidx_app_compat : '1.3.1',
androidx_card_view : '1.0.0',
androidx_constraint_layout: '1.1.3',
androidx_lifecycle : '2.0.0',
androidx_test_ext : '1.1.0',
androidx_recycler_view : '1.0.0',
androidx_room : '2.0.0',
]
versions.kotlin = '1.3.72'
}

repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}

/**
* The dependencies block configures the dependencies Gradle needs to use
* to build your project. The following line adds Android plugin for Gradle
* version 4.2.0 as a classpath dependency.
*/
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.38.0'
// How can we move this to the sample folder
//classpath deps.android.gradlePlugin
}
repositories {
google()
}
}

apply plugin: "com.github.ben-manes.versions"
// By default, the plugins {} DSL resolves plugins from the public Gradle Plugin Portal. Apply not
// needed when using this.
plugins {
// Checks for newer lib versions.
id "com.github.ben-manes.versions" version "0.39.0"
}
21 changes: 21 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
47 changes: 34 additions & 13 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,34 +1,55 @@
apply plugin: "kotlin"
apply plugin: 'maven'

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
plugins {
id 'java-library'
id 'kotlin'
id 'maven-publish'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin"

implementation "com.github.komputing:khex:1.1.0"
implementation "com.github.komputing:khex:1.1.2"

implementation "org.bouncycastle:bcprov-jdk15to18:1.68"
implementation "org.bouncycastle:bcprov-jdk15to18:1.69"

implementation 'com.squareup.moshi:moshi:1.8.0'
implementation "com.squareup.moshi:moshi:${versions.moshi}"
// TODO: it would be better to use the generated adapter by moshi
// but for that we should move the implementations in different modules
//kapt "com.squareup.moshi:moshi-kotlin-codegen:$versions.moshi"

implementation "com.squareup.okhttp3:okhttp:$versions.okhttp"

testImplementation 'org.assertj:assertj-core:3.19.0'

// (Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.jupiter}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${versions.jupiter}"
testRuntime "org.junit.jupiter:junit-jupiter-engine:${versions.jupiter}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${versions.jupiter}"

// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:${versions.jupiter}"

testImplementation "com.squareup.okhttp3:mockwebserver:$versions.okhttp"
}

test {
useJUnitPlatform()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

afterEvaluate {
publishing {
publications {
// Creates a Maven publication called “walletconnectPublication”.
walletconnectPublication(MavenPublication) {
// Applies the component for the debug build variant.
from components.java

groupId = 'com.github.WalletConnect'
artifactId = 'kotlin-walletconnect-lib'
version = '0.9.7'
}
}
}
}

54 changes: 31 additions & 23 deletions sample/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

defaultConfig {
Expand All @@ -19,49 +17,59 @@ android {
versionName '1.0.0'
}

dexOptions {
jumboMode = true
}

lintOptions {
textReport true
textOutput 'stdout'
checkDependencies true
}

/**
* The buildTypes block is where you can configure multiple build types.
* By default, the build system defines two build types: debug and release. The
* debug build type is not explicitly shown in the default build configuration,
* but it includes debugging tools and is signed with the debug key. The release
* build type applies Proguard settings and is not signed by default.
*/
buildTypes {

/**
* By default, Android Studio configures the release build type to enable code
* shrinking, using minifyEnabled, and specifies the default Proguard rules file.
*/
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
minifyEnabled false
}

release {
minifyEnabled true // Enables code shrinking for the release build type.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://www.jitpack.io' }
// The kotlinx-coroutines-core artifact contains a resource file that is not required for the coroutines to operate normally and is only used by the debugger. To exclude it at no loss of functionality, add the following snippet to the android block in your Gradle file for the application subproject:
// https://github.com/Kotlin/kotlinx.coroutines
packagingOptions {
resources.excludes += "DebugProbesKt.bin"
}
}

dependencies {
implementation project(":lib")
// Instead of adding ":lib" you could add the url below:
//implementation 'com.github.WalletConnect:kotlin-walletconnect-lib:0.9.6'

implementation "org.java-websocket:Java-WebSocket:1.4.0"

implementation "com.github.komputing:khex:1.0.0-RC6"
implementation "org.java-websocket:Java-WebSocket:1.5.2"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation "com.github.komputing:khex:$versions.k"

implementation "androidx.appcompat:appcompat:$versions.androidx_app_compat"
implementation "androidx.multidex:multidex:$versions.multidex"

implementation 'com.squareup.moshi:moshi:1.8.0'
implementation 'com.squareup.moshi:moshi:1.12.0'
implementation "com.squareup.okhttp3:okhttp:$versions.okhttp"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'

}
3 changes: 2 additions & 1 deletion sample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:supportsRtl="true"
android:name=".ExampleApplication"
android:networkSecurityConfig="@xml/network_config">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.walletconnect.example

import androidx.multidex.MultiDexApplication
import android.app.Application
import com.squareup.moshi.Moshi
import io.walletconnect.example.server.BridgeServer
import okhttp3.OkHttpClient
Expand All @@ -11,7 +11,7 @@ import org.walletconnect.nullOnThrow
import java.io.File
import java.util.*

class ExampleApplication : MultiDexApplication() {
class ExampleApplication : Application() {
override fun onCreate() {
super.onCreate()
initMoshi()
Expand Down
30 changes: 16 additions & 14 deletions sample/app/src/main/java/io/walletconnect/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package io.walletconnect.example

import android.app.Activity
import android.os.Bundle
import kotlinx.android.synthetic.main.screen_main.*
import android.content.Intent
import android.net.Uri
import android.view.View
import android.widget.Button
import android.widget.TextView
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -49,19 +50,19 @@ class MainActivity : Activity(), Session.Callback {

private fun sessionApproved() {
uiScope.launch {
screen_main_status.text = "Connected: ${ExampleApplication.session.approvedAccounts()}"
screen_main_connect_button.visibility = View.GONE
screen_main_disconnect_button.visibility = View.VISIBLE
screen_main_tx_button.visibility = View.VISIBLE
findViewById<TextView>(R.id.screen_main_status).text = "Connected: ${ExampleApplication.session.approvedAccounts()}"
findViewById<Button>(R.id.screen_main_connect_button).visibility = View.GONE
findViewById<Button>(R.id.screen_main_disconnect_button).visibility = View.VISIBLE
findViewById<Button>(R.id.screen_main_tx_button).visibility = View.VISIBLE
}
}

private fun sessionClosed() {
uiScope.launch {
screen_main_status.text = "Disconnected"
screen_main_connect_button.visibility = View.VISIBLE
screen_main_disconnect_button.visibility = View.GONE
screen_main_tx_button.visibility = View.GONE
findViewById<TextView>(R.id.screen_main_status).text = "Disconnected"
findViewById<Button>(R.id.screen_main_connect_button).visibility = View.VISIBLE
findViewById<Button>(R.id.screen_main_disconnect_button).visibility = View.GONE
findViewById<Button>(R.id.screen_main_tx_button).visibility = View.GONE
}
}

Expand All @@ -73,14 +74,14 @@ class MainActivity : Activity(), Session.Callback {
override fun onStart() {
super.onStart()
initialSetup()
screen_main_connect_button.setOnClickListener {
findViewById<Button>(R.id.screen_main_connect_button).setOnClickListener {
ExampleApplication.resetSession()
ExampleApplication.session.addCallback(this)
}
screen_main_disconnect_button.setOnClickListener {
findViewById<Button>(R.id.screen_main_disconnect_button).setOnClickListener {
ExampleApplication.session.kill()
}
screen_main_tx_button.setOnClickListener {
findViewById<Button>(R.id.screen_main_tx_button).setOnClickListener {
val from = ExampleApplication.session.approvedAccounts()?.first()
?: return@setOnClickListener
val txRequest = System.currentTimeMillis()
Expand Down Expand Up @@ -112,8 +113,9 @@ class MainActivity : Activity(), Session.Callback {
if (resp.id == txRequest) {
txRequest = null
uiScope.launch {
screen_main_response.visibility = View.VISIBLE
screen_main_response.text = "Last response: " + ((resp.result as? String) ?: "Unknown response")
val textView = findViewById<TextView>(R.id.screen_main_response)
textView.visibility = View.VISIBLE
textView.text = "Last response: " + ((resp.result as? String) ?: "Unknown response")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample/app/src/main/res/layout/screen_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
android:id="@+id/screen_main_disconnect_button"
android:layout_width="wrap_content"
android:layout_height="64dp"
android:text="Disonnect"
android:text="Disconnect"
android:visibility="gone" />
</LinearLayout>
Loading