Error Com.android.dx.command.main In Android Studio 2.3
Solution 1:
add multiDexEnabled true in default config file of build.gradle like this
defaultConfig {
multiDexEnabled true
}
Solution 2:
I found the reason, a file error log created in my app -- insufficient memory. I restart my computer and now I worked. But my computer 16Gb ram, Android Studio only use nearly 2Gb ram, but error still happen
hs_err_pid4936.log
There is insufficient memory for the Java Runtime Environment to continue. Native memory allocation (malloc) failed to allocate 604656 bytes for Chunk::new Possible reasons: The system is out of physical RAM or swap space In 32 bit mode, the process size limit was hit Possible solutions: Reduce memory load on the system Increase physical memory or swap space Check if swap backing store is full Use 64 bit Java on a 64 bit OS Decrease Java heap size (-Xmx/-Xms) Decrease number of Java threads Decrease Java thread stack sizes (-Xss) Set larger code cache with -XX:ReservedCodeCacheSize= This output file may be truncated or incomplete.
Out of Memory Error (allocation.cpp:390), pid=4936, tid=0x000000000000156c
JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode windows-amd64 compressed oops) Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
Solution 3:
You need to ensure that you didn't implement the multiple libraries in the same project. then project conflicted with both libraries. If you face the problem please read the solution step one by one and apply the process to your error project.
- Step 1
Your google play services library is being exported from other dependencies of your project and at the compile time the dex compiler gets confused. If you're using Gradle then including this in your project's build.gradle should exclude the support library from being exported into your main project.
apply plugin: 'android'
apply plugin: 'crashlytics'/** Must exclude exported support jars from dependencies, or get dex duplicate class error. **/
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
If you're using the android studio build system. Then you should go to File -> project structure and disable -> modules. Go through each module the and click on the dependency tab, unchecked the export column for for the support library and google play services library.
- Step 2
Make sure you have downloaded Support Repository to use support library dependency in build.gradle.
- Step 3
Because you may include two same libs in your project. check your build.gradle file.
dependencies {
compile'com.android.support:appcompat-v7:+'compile files('libs/android-support-v4.jar')
}
if your file includes compile 'com.android.support:appcompat-v7:+' and compile files*('libs/android-support-v4.jar')*, it will have this problems. delete this sentence: compile files('libs/android-support-v4.jar') To Change Make it
dependencies {
compile'com.android.support:appcompat-v7:+'
}
- Steep 4
If you are try the way but not solve the problem than this this another way . hope you will solve the problem. Simple go to Project Folder Remove .gradle .idea folder And Go to yourproject\apps\build Remove All Directory in this Build Folder Now go to Android Studio And sync your project with gradle once using the button.
I hope this will help.
Solution 4:
Try to disable instant run option, it's worked for me.
Solution 5:
This error mostly occurs when you create a new project based on an existing one.
Bellow was how i fixed it:
- First make sure you've set multiDexEnabled true
- Delete all generated folders like .gradle, .idea and build when your project is still opened in android studio.
- And then invalidate cache and restart the project.
I think it should work after that.
Post a Comment for "Error Com.android.dx.command.main In Android Studio 2.3"