如何解决我在Android Studio中遇到的这个错误:
错误:无法将请求的类适配到单个dex文件中(# methods: 67593 > 65536)
现在我的项目无法构建。
如何解决我在Android Studio中遇到的这个错误:
错误:无法将请求的类适配到单个dex文件中(# methods: 67593 > 65536)
现在我的项目无法构建。
请按以下4个步骤操作:
1:在应用的build.gradle文件中的依赖项中添加此库:
implementation 'com.android.support:multidex:1.0.3'
2:在应用的build.gradle文件中的defaultConfig中添加以下内容:
defaultConfig {
//other configs
multiDexEnabled true //add this line
}
3: 创建一个像这样的新Java类:
public class ApplicationClass extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
4: 将以下内容添加到您的清单文件中(在应用程序标签中):
<application
android:name=".ApplicationClass"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
我的Visual Studio 2019 Xamarin项目也出现了同样的问题,解决方法就像链接中提到的那样: 错误:无法将所请求的类放入单个dex文件中。请尝试提供主dex列表。#方法:72477>65536
multiDexEnabled true
在***.Droid项目的选项页面中勾选启用multiDex复选框即可解决该问题。