title: Android Studio and SMBJ
body: <p>I am trying to make a File List from my SMB Shared Folder with Android Studio.</p>
  <p>I want to press a Button in my Android App and then get the List stored as <code>*.txt</code> in my root or SD Card Root.</p>
  <p>I am using Android Studio API Version Level 30 and SMBJ Library.</p>
  <p>But I'm failing in connection for my SMB Share.</p>
  <p>When I press the button with the code its crashing without giving a Message on my Samsung Galaxy S20.</p>
  <p>I found that the crash happens on following 2 lines:</p>
  <pre><code>AuthenticationContext ac = new AuthenticationContext(&quot;admin&quot;, &quot;password123&quot;.toCharArray(),null);
  Session session = connection.authenticate(ac);
  </code></pre>
  <p>I am not sure if I need the domain.</p>
  <p>I have no domain installed and tried some different things.</p>
  <pre><code>            SMBClient client = new SMBClient();
  
              try {
                  Connection connection = client.connect(&quot;192.168.1.75&quot;);
                  AuthenticationContext ac = new AuthenticationContext(&quot;admin&quot;, &quot;password123&quot;.toCharArray(),null);
                  Session session = connection.authenticate(ac);
                  //DiskShare share = (DiskShare) session.connectShare(&quot;Intel&quot;);
              } catch (Exception e) {
                  txt.setText(e.toString());
              }
  </code></pre>
  <p>The following is from the SMBJ Website on GIT:
  <a href="https://github.com/hierynomus/smbj" rel="nofollow noreferrer">https://github.com/hierynomus/smbj</a></p>
  <pre><code>SMBClient client = new SMBClient();
  
  try (Connection connection = client.connect(&quot;SERVERNAME&quot;)) {
      AuthenticationContext ac = new AuthenticationContext(&quot;USERNAME&quot;, &quot;PASSWORD&quot;.toCharArray(), &quot;DOMAIN&quot;);
      Session session = connection.authenticate(ac);
  
      // Connect to Share
      try (DiskShare share = (DiskShare) session.connectShare(&quot;SHARENAME&quot;)) {
          for (FileIdBothDirectoryInformation f : share.list(&quot;FOLDER&quot;, &quot;*.TXT&quot;)) {
              System.out.println(&quot;File : &quot; + f.getFileName());
          }
      }
  }
  </code></pre>
  <p>This is the error log I get:</p>
  <pre><code>
  2022-04-25 11:45:27.475 22865-22865/com.example.filme E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.filme, PID: 22865
      java.lang.NoClassDefFoundError: Failed resolution of: Lorg/slf4j/LoggerFactory;
          at com.hierynomus.smbj.SMBClient.&lt;clinit&gt;(SMBClient.java:119)
          at com.example.filme.MainActivity$1.onClick(MainActivity.java:36)
          at android.view.View.performClick(View.java:7792)
          at android.widget.TextView.performClick(TextView.java:16112)
          at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
          at android.view.View.performClickInternal(View.java:7769)
          at android.view.View.access$3800(View.java:910)
          at android.view.View$PerformClick.run(View.java:30213)
          at android.os.Handler.handleCallback(Handler.java:938)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loopOnce(Looper.java:226)
          at android.os.Looper.loop(Looper.java:313)
          at android.app.ActivityThread.main(ActivityThread.java:8663)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
       Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;org.slf4j.LoggerFactory&quot; on path: DexPathList[[dex file &quot;/data/data/com.example.filme/code_cache/.overlay/base.apk/classes3.dex&quot;, dex file &quot;/data/data/com.example.filme/code_cache/.overlay/base.apk/classes.dex&quot;, zip file &quot;/data/app/~~SMMMBpkYv1Fu0fT2H1M_sA==/com.example.filme-ovE-fLeCY69AhQvQzyn1cA==/base.apk&quot;],nativeLibraryDirectories=[/data/app/~~SMMMBpkYv1Fu0fT2H1M_sA==/com.example.filme-ovE-fLeCY69AhQvQzyn1cA==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
          at com.hierynomus.smbj.SMBClient.&lt;clinit&gt;(SMBClient.java:119) 
          at com.example.filme.MainActivity$1.onClick(MainActivity.java:36) 
          at android.view.View.performClick(View.java:7792) 
          at android.widget.TextView.performClick(TextView.java:16112) 
          at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) 
          at android.view.View.performClickInternal(View.java:7769) 
          at android.view.View.access$3800(View.java:910) 
          at android.view.View$PerformClick.run(View.java:30213) 
          at android.os.Handler.handleCallback(Handler.java:938) 
          at android.os.Handler.dispatchMessage(Handler.java:99) 
          at android.os.Looper.loopOnce(Looper.java:226) 
          at android.os.Looper.loop(Looper.java:313) 
          at android.app.ActivityThread.main(ActivityThread.java:8663) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 
  2022-04-25 11:45:27.518 22865-22865/com.example.filme I/Process: Sending signal. PID: 22865 SIG: 9
  
  </code></pre>
  <p>tried to install library slf4j-android-1.7.9.jar
  but dont works for now.</p>
  <p>Edit 12:46 o clock:</p>
  <p>I added now many libraries and now its going close to work but not fully.</p>
  <p>No library is missing but the following error occurs:</p>
  <blockquote>
  <p>android.os.NetworkOnMainThreadException error</p>
  </blockquote>
  <p>I read that I must do asynchronous processing.</p>
  <p>But I'm too stupid to write this asynchronous code.. can anyone help?</p>