5

I built an app and I have different classes, and first I got an error like this when I tried to run the app

Cannot fit requested classes in a single dex file (# methods: 66087 > 65536)

I followed some instructions from Google and I added to my build.gradle

this dependency

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

and to the defaultConfig this

multiDexEnabled true

In my manifest xml I added this

android:name="android.support.multidex.MultiDexApplication"

but its highlighted with red color and when I move the cursor over it says

Unresolved class MultiDexApplication

When I try to run the app again it throws me

No file known for: classes2.dex

Known maps: {RelativeFile{base=/Users/***/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeDexDebug/out/classes.dex, path=classes.dex, type=DIRECTORY}=classes.dex, RelativeFile{base=/Users/****/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeProjectDexDebug/out/classes.dex, path=classes.dex, type=DIRECTORY}=classes3.dex, RelativeFile{base=/Users/*****/AndroidStudioProjects/****/app/build/intermediates/dex/debug/mergeExtDexDebug/out/classes2.dex, path=classes2.dex, type=DIRECTORY}=classes4.dex}

This is the MainActivity Class

package com.example.drivieapp;

import androidx.appcompat.app.AppCompatActivity;


import android.content.Intent;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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

         final Intent i = new Intent(this, screenNotLogged.class );
        Thread timer = new Thread() {

            public void run() {
                try {
                    sleep(3100);
                }
                catch(InterruptedException e) {
                    e.printStackTrace();
                }
                finally {
                   startActivity(i);
                   finish();

                }
            }
        };
        timer.start();
    }
}


Can you please explain me what I have to do? I google the solution but didn't understand too much. Thank you very much!

Manifest xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="****">

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="Drivie"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:name="android.support.multidex.MultiDexApplication"

    >
        <activity android:name=".SignupCarrier"></activity>
        <activity android:name=".carrierSignupHint" />
        <activity android:name=".home" />
        <activity android:name=".SignupSender" />
        <activity android:name=".signup" />
        <activity android:name=".screenNotLogged" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Calin Onaca
  • 175
  • 3
  • 14

1 Answers1

-1
cd android 
./gradlew clean 
cd .. 
npx react-native run-android

It seems that the error message you received is related to the build process of an Android app. The error message "No file known for: classes.dex" usually occurs when the build process fails to generate the classes.dex file. This file is generated by the Android build system and contains all the compiled Java code of your app.

There are several reasons why this error might occur. One possible reason is that there is a problem with your Gradle configuration. You can try cleaning your project and rebuilding it to see if that fixes the issue. Another possible reason is that there is a problem with your Android SDK installation. You can try reinstalling the SDK to see if that helps.

I hope this helps! Let me know if you have any other questions.

Source: Conversation with Bing, 5/14/2023

(1) android - Where is classes.dex file - Stack Overflow. Where is classes.dex file. (2) What does 'No file known for: classes2.dex' mean?. What does 'No file known for: classes2.dex' mean?. (3) A failure occurred while executing com.android.build.gradle.internal .... A failure occurred while executing com.android.build.gradle.internal.tasks.

#react-native

مصطفى
  • 555
  • 4
  • 9