Chiogros opened a new pull request, #882:
URL: https://github.com/apache/mina-sshd/pull/882

   Hi 👋🏻 ,
   
   I'm developing [Trante](https://github.com/Chiogros/Trante), an Android app 
to allow remote storage access from Android's file manager.
   I used _mina-sshd_ for SFTP access to remote servers and I wanted to 
contribute back to help future developers to use it.
   
   This PR brings:
   - a complete Kotlin example
   - a link to my app as a demo, with direct reference to the class handling 
sshd-sftp calls
   - Proguard instructions to help with app optimizations
   - moving examples first and issues + next features then
   
   I addition,
   > we would appreciate feedback on problems and solutions our users have 
encountered when running on Android
   
   so here it is. Short disclaimer: it's been a few months since I've managed 
to use _sshd-sftp_, so I can't remember about every _why is that working this 
way?_.
   
   1. Configuring filesystem.
   The existing example didn't do the trick for me. I targeted Android SDK 35 
and as far as I can remember, I couldn't get a `Path` to use in `Supplier` 
because some methods were not available anymore on the JDK. After some digging, 
here's what worked:
   ```kotlin
   // Set Android's filesystem path
   val path: Supplier<Path> = Supplier { Paths.get("") }
   setUserHomeFolderResolver(path)
   val client: SshClient = SshClient.setUpDefaultClient()
   
   client.start()
   ```
   
   2. Concurrent lib connections
   
   3. Release builds
   Only during release builds, the app crashed. During release builds, 
[R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization)
 (an app optimizer) struggles to find any reference to some code pieces in the 
library using 
[reflection](https://developer.android.com/topic/performance/app-optimization/library-optimization#use-codegen)
 and deletes those from the final build. Unfortunately at runtime, these 
deleted pieces of code were really needed for the app to work.
   After hours of build & trial, I've figured out which classes need to be 
protected from R8 wiping. It led to this `proguard-rules.pro` ruleset:
   ```
   -keep,allowoptimization,allowobfuscation class 
org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory { *; }
   -keep,allowoptimization,allowobfuscation class 
org.apache.sshd.common.session.helpers.SessionHelper { *; }
   -keep,allowoptimization class 
org.apache.sshd.common.util.security.bouncycastle.BouncyCastleSecurityProviderRegistrar
 { *; }
   -keep,allowoptimization class 
org.apache.sshd.common.util.security.eddsa.EdDSASecurityProviderRegistrar { *; }
   -keep,allowoptimization class 
org.apache.sshd.common.util.security.SunJCESecurityProviderRegistrar { *; }
   -dontwarn org.apache.sshd.**
   ``` 
   
   Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to