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

For resolve this error follow these steps:

Fristly create android project ,type name like MyApplication3 (Maintion in this project)
if you do'nt know how to create android project ,then follow below link

How to create android project in android studio

Type below code in activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"

tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.gms.ads.AdView
android:id="@+id/adview"
android:layout_width="match_parent"
android:layout_height="63dp"
ads:adSize="LARGE_BANNER"
ads:adUnitId="ca-app-pub-6170006774994819/4974882782"
>

</com.google.android.gms.ads.AdView>


</RelativeLayout>





Type below code in app level gradle file


 plugins {

    id 'com.android.application'
}

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled=true


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.firebase:firebase-ads:20.5.0'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.google.android.gms:play-services-auth:20.0.1'
apply plugin:'com.google.gms.google-services'

implementation 'androidx.multidex:multidex:2.0.1'


androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}



Type below code in project level gradle file

// 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:4.1.3"
classpath 'com.google.gms:google-services:4.3.10'

// 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
}


    
    
    
    




    
    Type below code in AndroidManifest.xml

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

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication" >
<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>

Connect android project to firebase

How to connect android project to firebase in android studio

Download google-services.json file from firebase



Comments

Popular posts from this blog

How to authenticate mobile number in android studio

How to connect android project to Firebase

How to create a new activity in existing android project in android studio

How to Create a Custom menu in android studio

How to create android project in android studio

How to add(Part-2) Video in FirebaseRecyclerAdapter in android studio

How to download google-services.json file from firebase

How to Add Like,Dislike button in video in android studio

How to create Layout Resource File in existing project in android studio

How to add Video(Part-1) in FirebaseRecyclerAdapter from Galllary..