Android studio cannot run the command: Java – xmx1024m – CP
•
Android
Today, I encountered this problem when I was running a program using Android. Gradle would make an error like this:
Can you help me?
resolvent:
Setting up an application development project to use multidex configuration requires some modifications to the application development project. In particular, you need to perform the following steps:
>Change your gradle build configuration to enable multidex > Modify manifest to reference the multidexapplication class
Modify your gradle build file configuration to include support libraries and enable multidex output
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Read the relevant official document multidex
If your application class is extending some other classes and you don't want or can't change it, override attachbasecontext(), as follows:
public class MyApplication extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码