在app的build.gradle文件中加入以下代码解决该问题:
android {
...
// Change file type of bundled pattern to APK
packagingOptions {
pickFirst 'META-INF/plex.properties'
pickFirst '**/*.so'
pickFirst '**/*.jar'
pickFirst 'lib/**/*'
pickFirst 'assets/**/*'
pickFirst 'res/**/*'
pickFirst 'resources.arsc'
pickFirst 'AndroidManifest.xml'
pickFirst 'app.apk'
// Override bundled plugin file type
exclude 'META-INF/plex.properties'
exclude '**/*.so'
exclude '**/*.jar'
exclude 'lib/**/*'
exclude 'assets/**/*'
exclude 'res/**/*'
exclude 'resources.arsc'
exclude 'AndroidManifest.xml'
include('*.apk') {
// Set file type to APK
from { null }
into 'APK'
include '*.apk'
}
}
}
该方法将“*.apk”文件匹配模式的文件类型从“bundled”更改为“APK”。