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

Improve android example #1173

Merged
merged 15 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Execute with a timeout can ignore timeout and block indefinitely in CI tests
- The Android example can now be run with the local SDK version

## 2.17.4

Expand Down
9 changes: 9 additions & 0 deletions example-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ Running the example requires `operator_id` and `operator_key` resource strings t
<string name="operator_id">...</string>
<string name="operator_key">...</string>
```

## Running with a local SDK version

By default, the example uses the SDK version published on Maven Central. If you want to use the local version you need to do this:

- Publish the SDK to the local Maven repo - `./gradlew :sdk:publishToMavenLocal`
- Uncomment the `mavenLocal()` line in `example-android/build.gradle`
- Build the example - `./gradlew :example-android:build --refresh-dependencies`
- Run the example
58 changes: 24 additions & 34 deletions example-android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
plugins {
id "com.android.application"
id "kotlin-android"
}

android {
compileSdkVersion 32
compileSdkVersion 33

defaultConfig {
applicationId "com.hedera.android_example"
minSdkVersion 24
targetSdkVersion 32
targetSdkVersion 33
versionCode 1
versionName "1.0"

Expand All @@ -22,60 +24,48 @@ android {
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

namespace 'com.hedera.android_example'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

// for the sdk
//implementation 'com.hedera.hashgraph:sdk:2.14.0'
// NOTE: BouncyCastle is frozen at v1.60 for compatibility with Corda <https://www.corda.net/>
// <https://github.com/corda/corda/blob/2c10b6c3b9dace7831b5da73a065c3269a703d85/constants.properties#L23>
implementation "org.bouncycastle:bcprov-jdk15on:1.70"

// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'com.hedera.hashgraph:sdk-jdk7:2.17.4'

implementation "com.google.code.gson:gson:2.9.1"
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation "com.esaulpaugh:headlong:8.0.0"
implementation files('../../sdk/build/libs/sdk-2.17.4.jar')
implementation 'org.slf4j:slf4j-simple:2.0.3'
implementation 'io.grpc:grpc-okhttp:1.46.0'
implementation 'com.hedera.hashgraph:sdk-jdk7:2.17.4'

implementation "net.sourceforge.streamsupport:streamsupport:1.7.4"
implementation "net.sourceforge.streamsupport:streamsupport-cfuture:1.7.4"

// NOTE: This is to support Android API < 26.
implementation "org.threeten:threetenbp:1.6.0"
implementation 'org.slf4j:slf4j-simple:2.0.3'
implementation 'io.grpc:grpc-okhttp:1.46.0'

implementation "io.grpc:grpc-protobuf-lite:1.46.0"

// Protobuf Lite is used to maintain easy compatibility with Android
// https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
implementation "com.google.protobuf:protobuf-javalite:3.21.1"

implementation "io.grpc:grpc-core:1.48.1"
implementation "io.grpc:grpc-stub:1.48.1"

// https://mvnrepository.com/artifact/com.github.spotbugs/spotbugs-annotations
implementation group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '4.7.1'
}

repositories {
mavenCentral()
}
16 changes: 7 additions & 9 deletions example-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.7.10'

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

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.quittle:android-emulator-plugin:0.4.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -19,14 +21,10 @@ buildscript {

allprojects {
repositories {
// resolve locally installed version first (mostly for CI, you can omit this)
mavenLocal()
// Uncomment if you want to use the local SDK version
// mavenLocal()
google()
// hashgraph SDK is published to Maven Central only
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Binary file added example-android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion example-android/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-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading