Simple program gets "Cannot fit requested classes in a single dex file" when adding Firestore dependency

gets() function in c
gets function in c example
gets() function in c example
fgets
gets and puts function in c
implicit declaration of function gets
scanf
getchar() in c

I have a very simple program that runs fine--until I add the library dependencies to connect with Firestore. Specifically, when I add implementation 'com.google.firebase:firebase-firestore:21.2.0' to my app gradle. (Changing to an earlier 17.x.x version makes no difference). The error is "Cannot fit requested classes in a single dex file", which to me makes no sense since the program is so simple: no way I have more than 64K methods running.

Here is the MainActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void addUnitType(View view) {
    return;
}

}

...here is activity_main.XML

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/edit_unit_type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_marginStart="7dp"
        android:hint="Unit Type (MedSurg, ICU, etc)"
        android:inputType="text"
        android:textSize="10sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

...this is the project gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

...this is the app gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.nofirestore"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    **implementation 'com.google.firebase:firebase-firestore:21.2.0'**
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
}

And again, this is the offending code in the app gradle--remove it and I am fine, put it in the dependencies and the compiling crashes:

implementation 'com.google.firebase:firebase-firestore:21.2.0'

and this the error

"Cannot fit requested classes in a single dex file"

Any thoughts on what gives? I have run much more complex apps without the need for multidex. I would love to know. Thank you.


Well, it was NOT the missing

apply plugin: 'com.google.gms.google-services'

Instead, it was something as simple as the minSdkVersion19: changing that to 22 got rid of the multidex compiling error, and it runs fine!

GETS in C Programming, Gets in C Programming Example. The gets function used to read the complete set of characters from the console. This program will help you to understand this  gets () is used to take a single input at a time but can be used to input a complete sentence with spaces unlike scanf (). Below is a program on use of gets (). gets () takes only a single line at a time i.e all the words before hitting (enter key).


Updating the minSdkVersion to 22 in the app level build.gradle worked on its own. There was no need for me to enter the multiDexEnabled settings noted above.

fgets() and gets() in C language, with spaces, we can use either gets() or fgets() in C programming language. Example : Suppose we have a character array of 15 characters and input is  C gets () function. The gets () function enables the user to enter some characters followed by the enter key. All the characters entered by the user get stored in a character array. The null character is added to the array to make it a string. The gets () allows the user to enter the space-separated strings.


Inside the defaultConfig block add the following:

multiDexEnabled true

Also in the build.gradle add the following dependency:

implementation 'com.android.support:multidex:1.0.3'

You can check more information about multidex in the following link:

https://developer.android.com/studio/build/multidex

C gets() and puts(), C gets() and puts() functions with programming examples for beginners and professionals covering concepts, control statements. Let's see a simple program to  gets () : Reads characters from the standard input and stores them as a string. puts () : prints characters from the standard output.Just like printf statement.


Program to show usage of gets() function in C, Program on use of gets() function to input character in C language with output for practice and interview/exam preparation in C Language. I guess the reason is simple: you didn't halt/abort your program in the execs.That address 0xb76f2300 is on stack, so I suspect it is the return from the execs that fails when it tries to return to the value of the stored stack pointer.


C Programming Gets() Function Tutorial with Examples – POFTUT, Example. In this example, we will get the name from standard input and put into char array or string str then print with printf()  About GETS The Government Emergency Telecommunications Service (GETS) provides NS/EP personnel priority access and prioritized processing in the local and long distance segments of the landline networks, greatly increasing the probability of call completion.


C++ gets() - C++ Standard Library, The gets() function in C++ reads characters from stdin and stores them until a newline character is found or end of file occurs. Example: How gets() function works. #include <iostream> When you run the program, a possible output will be: name = gets. This next line is a little more involved. Let’s break it down. The gets method tells the computer to wait for input from the keyboard. This pauses the program, allowing the user to enter any text they want. The program will continue when the user presses the ENTER key on their keyboard.