title: I can't connect my Android app to MongoDB
body: <p>I have an error and I don't even know how to read this or what is wrong, here is the code:</p>
  
  <pre><code>
  import android.os.Bundle;
  import android.widget.TextView;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import com.mongodb.MongoClient;
  import com.mongodb.MongoClientURI;
  import com.mongodb.client.MongoDatabase;
  import com.mongodb.client.MongoIterable;
  
  
  
  public class MainActivity extends AppCompatActivity {
      TextView dataBase;
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          dataBase = (TextView) findViewById(R.id.db);
          MongoClientURI uri = new MongoClientURI(
                  "mongodb+srv://Razvan:justforfun@cluster0-27vbb.mongodb.net/test?retryWrites=true&amp;w=majority");
  
          MongoClient mongoClient = new MongoClient(uri);
          MongoDatabase database = mongoClient.getDatabase("Location");
          MongoIterable&lt;String&gt; collections = database.listCollectionNames();
          for (String collectionName: collections) {
              System.out.println(collectionName);
              dataBase.setText(collectionName);
      }
      }}
  </code></pre>
  
  <p>And here ie my error:</p>
  
  <pre><code>2019-12-15 17:51:52.734 29344-29344/? E/Zygote: isWhitelistProcess - Process is Whitelisted
  2019-12-15 17:51:53.302 29344-29344/com.example.testaddtodb E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.testaddtodb, PID: 29344
      java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/naming/directory/InitialDirContext;
          at com.mongodb.internal.dns.DnsResolver.createDnsDirContext(DnsResolver.java:140)
          at com.mongodb.internal.dns.DnsResolver.resolveHostFromSrvRecords(DnsResolver.java:58)
          at com.mongodb.ConnectionString.&lt;init&gt;(ConnectionString.java:325)
          at com.mongodb.MongoClientURI.&lt;init&gt;(MongoClientURI.java:238)
          at com.mongodb.MongoClientURI.&lt;init&gt;(MongoClientURI.java:220)
          at com.example.testaddtodb.MainActivity.onCreate(MainActivity.java:55)
          at android.app.Activity.performCreate(Activity.java:7183)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
          at android.app.ActivityThread.-wrap11(Unknown Source:0)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
          at android.os.Handler.dispatchMessage(Handler.java:105)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6944)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
       Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.naming.directory.InitialDirContext" on path: DexPathList[[zip file "/data/app/com.example.testaddtodb-pUt_yDyfjwK1W3EqtvcFaw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.testaddtodb-pUt_yDyfjwK1W3EqtvcFaw==/lib/arm64, /system/lib64, /system/vendor/lib64]]
          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
          ...
  </code></pre>
  
  <p>What is wrong with "MongoClientURI uri..."?
  I want to connect my Android app to a MongoDB test database, but I get this error and I don't even know how to read this...</p>
  
  <p>Thank you! </p>