Skip to content

Commit 327d4ce

Browse files
committed
fix(jgit): downgrade JGit to fix readNBytes crash on Android 9/10 (#6)
1 parent 2e77215 commit 327d4ce

5 files changed

Lines changed: 13 additions & 17 deletions

File tree

app/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ dependencies {
102102
implementation(libs.androidx.datastore.preferences)
103103

104104
// Third-party Libraries
105-
implementation(libs.org.eclipse.jgit)
106-
implementation(libs.org.eclipse.jgit.ssh.jsch) {
105+
implementation(libs.org.eclipse.jgit) {
107106
exclude(group = "com.jcraft", module = "jsch")
107+
exclude(group = "org.bouncycastle", module = "bcprov-jdk15on")
108+
exclude(group = "org.bouncycastle", module = "bcpkix-jdk15on")
108109
}
109110
implementation(libs.jsch)
110111
implementation(libs.bouncycastle)

app/proguard-rules.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
-keep class org.eclipse.jgit.internal.** { *; }
6767
-keep class org.eclipse.jgit.pgm.** { *; }
6868

69-
# JGit SSH JSCH
70-
-keep class org.eclipse.jgit.transport.ssh.jsch.** { *; }
69+
# JGit SSH
70+
-keep class org.eclipse.jgit.transport.JschConfigSessionFactory { *; }
7171

7272
# Apache MINA SSHD (used by JGit SSH)
7373
-keep class org.apache.sshd.** { *; }

app/src/main/java/jamgmilk/fuwagit/data/jgit/JGitCoreDataSource.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class JGitCoreDataSource @Inject constructor(
252252

253253
command.setTransportConfigCallback { transport ->
254254
if (transport is org.eclipse.jgit.transport.SshTransport) {
255-
transport.sshSessionFactory = object : org.eclipse.jgit.transport.ssh.jsch.JschConfigSessionFactory() {
255+
transport.sshSessionFactory = object : org.eclipse.jgit.transport.JschConfigSessionFactory() {
256256
override fun createDefaultJSch(fs: org.eclipse.jgit.util.FS?): com.jcraft.jsch.JSch {
257257
val jsch = super.createDefaultJSch(fs)
258258
try {
@@ -274,6 +274,10 @@ class JGitCoreDataSource @Inject constructor(
274274
}
275275
return jsch
276276
}
277+
278+
override fun configure(host: org.eclipse.jgit.transport.OpenSshConfig.Host, session: com.jcraft.jsch.Session) {
279+
// No additional configuration needed
280+
}
277281
}
278282
}
279283
}

app/src/main/java/jamgmilk/fuwagit/data/jgit/JGitRemoteDataSource.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ class JGitRemoteDataSource @Inject constructor(
4646
.setDirectory(targetDir)
4747
.setCloneAllBranches(options.cloneAllBranches)
4848

49-
if (options.depth != null && options.depth > 0) {
50-
cloneCommand.setDepth(options.depth)
51-
}
5249
if (options.isBare) {
5350
cloneCommand.setBare(true)
5451
}

gradle/libs.versions.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
[versions]
22
agp = "9.2.1"
3-
coreKtx = "1.18.0"
3+
coreKtx = "1.19.0"
44
junit = "4.13.2"
5-
junitVersion = "1.3.0"
6-
espressoCore = "3.7.0"
75
lifecycleRuntimeKtx = "2.10.0"
86
activityCompose = "1.13.0"
97
kotlin = "2.3.21"
108
composeBom = "2026.05.01"
11-
orgEclipseJgit = "6.8.0.202311291450-r"
9+
orgEclipseJgit = "5.7.0.202003090808-r"
1210
documentfile = "1.1.0"
13-
jsch = "2.28.2"
11+
jsch = "2.28.3"
1412
securityCrypto = "1.1.0"
1513
bouncycastle = "1.84"
1614
navigation = "2.9.8"
@@ -34,7 +32,6 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
3432
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
3533
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
3634
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
37-
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
3835
androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
3936
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
4037
androidx-compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
@@ -50,7 +47,6 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version
5047

5148
# Third-party Libraries
5249
org-eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "orgEclipseJgit" }
53-
org-eclipse-jgit-ssh-jsch = { module = "org.eclipse.jgit:org.eclipse.jgit.ssh.jsch", version.ref = "orgEclipseJgit" }
5450
jsch = { module = "com.github.mwiede:jsch", version.ref = "jsch" }
5551
bouncycastle = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncycastle" }
5652
bouncycastle-pkix = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bouncycastle" }
@@ -63,8 +59,6 @@ hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-com
6359

6460
# Test Dependencies
6561
junit = { group = "junit", name = "junit", version.ref = "junit" }
66-
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
67-
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
6862
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics", version.ref = "uiGraphics" }
6963

7064
[plugins]

0 commit comments

Comments
 (0)