android studio打包apk两个bug解决办法

1、Error:(4) Error: "xxxxxxxxx" is translated here but not found in default locale [ExtraTranslation]

设置lint遇到错误时不终止程序,在build.gradle中加入

lintOptions {
	abortOnError false
	disable 'MissingTranslation'
}


2、Error:duplicate files during packaging of APK D:\project\android_work\test_mobile\test\build\outputs\apk\xxxxxx-release-unaligned.apk

Path in archive: lib/arm64-v8a/xxxxxxx.so

Origin 1: D:\project\android_work\test_mobile\test\libs\arm64-v8a\xxxxx.so

Origin 2: D:\project\android_work\test_mobile\test\build\intermediates\ndk\release\lib\arm64-v8a\xxxxx.so

You can ignore those files in your build.gradle:

android {

 packagingOptions {

   exclude 'lib/arm64-v8a/xxxxx.so'

 }

}

按提示,直接在build.gradle中加入下边配置并没有解决问题,

packagingOptions {

   exclude 'lib/arm64-v8a/xxxxx.so'

 }

在ide里面直接运行时app使用的是libs库文件夹里面的so库,而在打包apk时,由于项目中有jni源码,都会重新编译jni代码,导出build\intermediates\ndk\release\lib目录下也相同的so库,在build.gradle中加入

sourceSets {
	main {
		jni.srcDirs = []   //disable automatic ndk-build call
		jniLibs.srcDirs = ['libs']
	}
}

删除D:\project\android_work\test_mobile\test\build\intermediates\ndk\release下的文件

你可能感兴趣的:(android studio打包apk两个bug解决办法)