0

I'm creating an Android extension intended to connect to a remote SSH host based on the well known JSch library, so that once the button is pressed, the class is instantiated this way, with no compilation error:

JSch jsch = new JSch();

...but, application crashes!

Looking at the JSch() constructor, there is nothing inside:

public JSch(){
// here there are several commented instructions that need to be
// used just at MAC operational systems (not my OS).
}

If I remove initiation, compiler complains that variable jsch is not initalized.

JSch jsch;

Once I'm compiling with Apache Ant, there is no debug resources that I could use to trace the runtime error.

All tests are being made either within threads or callback methods, giving the same result; I simply cannot initiate the jsch variable, this yields a runtime exception com.jcraft.jsch.JSch. Does someone has some insights on how to solve that issue ?

  • 2
    Can you pls share the error stacktrace? – priyank-sriv May 02 '19 at 15:27
  • Is there any static initialization code in JSch? – Steve Smith May 02 '19 at 15:30
  • Use Logcat to examine the Java stack trace: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare May 02 '19 at 15:31
  • There is no way to do that, the application run at a mobile that is not connected to anything, I mean, the .apk package is being downloaded via MIT APP INVENTOR companion tool via Wi-fi connection so that as said, there is no debug resources available so far. – andre castro May 02 '19 at 15:33
  • @CommonsWare 1, thanks for your reply, but I'm using an outdated toolset, the Apache Ant, which just build and I have no access to the Mobile in debug mode. – andre castro May 02 '19 at 15:35
  • Um, you are going to need to address that. If you have no access to debug logs, I have no idea how you will succeed. Taking some blind guesses: make sure you are requesting the `INTERNET` permission, and make sure that you only use `Jsch` on a background thread. – CommonsWare May 02 '19 at 15:38
  • Regardless of anything, by focusing on the code above, are my observations correct? I mean, if the constructor is empty, should the simple instantiation at runtime cause runtime error? – andre castro May 02 '19 at 15:41
  • Yes, I've added: @UsesPermissions(permissionNames = "android.permission.INTERNET") **Note** *This is an Android extension* – andre castro May 02 '19 at 15:41
  • In short, the question is more related to language itself; based on what was presented in the above question, am I having wrong assumptions? – andre castro May 02 '19 at 15:50

1 Answers1

0

I was able to install the Android SDK-tools and after capturing the Log via line command ADB logcat > file.txt, there were the following sentence many times:

java.lang.NoClassDefFoundError: com.jcraft.jsch.JSch

Which means that the extension file (.aix) compiled with apache command ant extensions did not embed the above class within it. This explains the issue at all (application crashing instantiating above constructor - absent), and the next step is to discover how to encapsulate dependencies - surely in another thread, if I will not be able to do on my own.