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

Fix compatibility on Android platforms below Android API 28 #543

Merged
merged 20 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
# minSdk and targetSdk, see ${project_root}/android_test/app/build.gradle.kts
# TODO: Investigate why it is unstable on API 33.
emulator: [
{ api-level: 26, target: google_apis },
{ api-level: 23, target: google_apis },
{ api-level: 32, target: playstore }
]
steps:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
As this project is pre 1.0, breaking changes may happen for minor version bumps. A breaking change will get clearly notified in this log.

## Pending
* Add `org.stellar.sdk.spi.SdkProvider`, users can implement this interface to provide their own implementation of the SDK. We provide an [Android specific implementation](https://github.com/stellar/java-stellar-sdk-android-spi), if you are integrating this SDK into an Android project, be sure to check it out. ([#543](https://github.com/stellar/java-stellar-sdk/pull/543))
* Remove `commons-codec:commons-codec:1.16.0`. ([#543](https://github.com/stellar/java-stellar-sdk/pull/543))

## 0.41.0
* Add support for Soroban Preview 11. ([#530](https://github.com/stellar/java-stellar-sdk/pull/530))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ xdr/Stellar-contract-spec.x \
xdr/Stellar-contract.x \
xdr/Stellar-internal.x \
xdr/Stellar-contract-config-setting.x

# TODO: update XDRGEN_COMMIT
XDRGEN_COMMIT=f0c41458ca0b66b4649b18deddc9f7a11199f1f9
XDRNEXT_COMMIT=9ac02641139e6717924fdad716f6e958d0168491

Expand Down
14 changes: 10 additions & 4 deletions android_test/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {

defaultConfig {
applicationId = "org.stellar.javastellarsdkdemoapp"
minSdk = 26
minSdk = 23
targetSdk = 33
versionCode = 1
versionName = "1.0"
Expand All @@ -30,6 +30,11 @@ android {
}
}
compileOptions {
// Flag to enable support for the new language APIs
// For AGP 4.1+
// https://developer.android.com/studio/write/java8-support
isCoreLibraryDesugaringEnabled = true

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand All @@ -50,7 +55,9 @@ android {
}

dependencies {

// For AGP 7.4+
// https://developer.android.com/studio/write/java8-support
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.activity:activity-compose:1.7.2")
Expand All @@ -59,15 +66,14 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation(files("libs/stellar-sdk.jar"))
// Since we are adding local jar(libs/stellar-sdk.jar) as dependency,
// gradle cannot automatically download the required third-party dependencies.
implementation(files("libs/stellar-sdk.jar"))
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("com.squareup.okhttp3:okhttp-sse:4.11.0")
implementation("com.moandjiezana.toml:toml4j:0.7.2")
implementation("com.google.code.gson:gson:2.10.1")
implementation("net.i2p.crypto:eddsa:0.3.0")
implementation("commons-codec:commons-codec:1.16.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0-alpha03")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private const val PACKAGE = "org.stellar.javastellarsdkdemoapp"
@RunWith(AndroidJUnit4::class)
class MainInstrumentedTest {
@Test
fun testGetNetwork() {
fun testSDK() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
// open app
device.pressHome()
Expand All @@ -41,22 +41,22 @@ class MainInstrumentedTest {
)

// get text
val textNoNetworkInfo = device.wait(
Until.findObject(By.text("No network info")),
val textNoTestResult = device.wait(
Until.findObject(By.text("Not Run")),
ONE_MINUTE
)
assertNotNull(textNoNetworkInfo)
assertNotNull(textNoTestResult)

// get button
val button = device.wait(
Until.findObject(By.text("Get Network")),
Until.findObject(By.text("Run Test")),
ONE_MINUTE
)
assertNotNull(button)

// click button and wait text to appear
button.click()

assertTrue(device.wait(Until.hasObject(By.text("public")), ONE_MINUTE * 5))
assertTrue(device.wait(Until.hasObject(By.text("SUCCESS")), ONE_MINUTE * 5))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.stellar.javastellarsdkdemoapp
Copy link
Contributor

@sreuland sreuland Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once https://github.com/overcat/java-stellar-sdk-android-spi is published to jitpack, this can go away correct, and change this example to have dep on that instead?

[edit] oh, actually, i see it's already published to jitpack as a snapshot!

https://jitpack.io/#overcat/java-stellar-sdk-android-spi/-SNAPSHOT


import org.stellar.sdk.Base64
import org.stellar.sdk.spi.SdkProvider

class AndroidSdkProvider : SdkProvider {
override fun createBase64(): Base64 {
return AndroidBase64()
}

class AndroidBase64 : Base64 {
override fun encodeToString(data: ByteArray?): String {
return android.util.Base64.encodeToString(data, android.util.Base64.NO_WRAP)
}

override fun encode(data: ByteArray?): ByteArray {
return android.util.Base64.encode(data, android.util.Base64.NO_WRAP)
}

override fun decode(data: String?): ByteArray {
return android.util.Base64.decode(data, android.util.Base64.NO_WRAP)
}
}
}
Loading
Loading