as打包报 MissingTranslation 的解决办法

本文介绍了解决Android Studio在打包生成apk过程中遇到的编译错误问题,特别是string.xml文件中出现的“stringvalueisnottranslatedinzh(Chinese)[MissingTranslation]”警告。提供了三种有效的解决方法。

Android studio打包生成android apk的时候遇到了编译问题,AS生成apk的时候自己走了translate in english的路线。

几个string.xml文件报错 string value is not translated in "zh"(Chinese)[MissingTranslation]。


通过查找解决方案,发现有三种方案可以解决:

1、 在string 里加attribute      translatable="false":

<string name="hello_world" translatable="false">你好</string>

2、直接设定 string.xml文件内的resources的attribute:

<resources
   xmlns:tools="http://schemas.android.com/tools"
   tools:ignore="MissingTranslation">
    <string name="hello_world">你好</string>
</resources>

3、 File–>Setting–>Editor下的Inspections–>Android Lint 下的 Incomplete translation勾选去掉(不是很推荐,这是在google上找到的一种方法,试了一下不可以)




""" autoResign 工程打包方案 """ import os import shutil import sys import PyInstaller.__main__ # 1. 安装必要依赖 # pip install pyinstaller # pip install pywin32 (Windows签名需要) # 2. 打包配置 def package_project(): # 工程文件列表(根据实际调整) resource_files = [ "hap-sign-tool.jar", "OpenHarmony.p12", "OpenHarmonyApplication.pem", "OpenHarmonyProfileDebug.pem", "OpenHarmonyProfileRelease.pem", "README_ZH.md", "resign.p7b", "SgnedReleaseProfileTemplate.p7b", "UnsgnedDebugProfileTemplate.json", "UnsgnedReleasedProfileTemplate.json", "命令.txt" ] try: import PIL except ImportError: print("⚠️ 检测到缺少 Pillow 库,正在安装...") import subprocess try: subprocess.check_call([sys.executable, "-m", "pip", "install", "Pillow"]) print("✅ Pillow 安装成功") except Exception as e: print(f"❌ Pillow 安装失败: {str(e)}") print("⚠️ 将跳过图标处理") # 从参数中移除图标选项 resource_files = [arg for arg in resource_files if not arg.startswith("--icon")] # 创建临时资源目录 resource_dir = "app_resources" os.makedirs(resource_dir, exist_ok=True) # 复制资源文件到临时目录 for file in resource_files: if os.path.exists(file): shutil.copy(file, resource_dir) else: print(f"⚠️ 警告:文件不存在 - {file}") # PyInstaller配置选项 pyinstaller_args = [ "autoResign_exe.py", # 主程序入口 "--onefile", # 打包为单个可执行文件 "--name=autoResign_exe", # 生成的可执行文件名 "--add-data", f"{resource_dir}{os.pathsep}.", # 包含资源目录 "--icon=app_icon.ico", # 图标文件(可选) "--console", # 显示控制台窗口 # "--noconsole", # 无控制台版本(GUI应用) "--clean", # 清理临时文件 "--distpath=dist" # 输出目录 ] # 添加Windows签名支持(可选) if os.name == "nt": pyinstaller_args.extend([ "--uac-admin", # 请求管理员权限 "--version-file=version_info.txt" # 版本信息文件 ]) # 3. 执行打包命令 print("🚀 开始打包工程...") PyInstaller.__main__.run(pyinstaller_args) # 4. 清理临时文件 print("🧹 清理临时文件...") shutil.rmtree("build", ignore_errors=True) shutil.rmtree(resource_dir, ignore_errors=True) os.remove("autoResign_exe.spec") print("✅ 打包完成!可执行文件位于 dist/autoResign_exe.exe") # 5. 版本信息文件(version_info.txt)示例内容 """ VSVersionInfo( ffi=FixedFileInfo( filevers=(1, 0, 3, 0), prodvers=(1, 0, 0, 0), mask=0x3f, flags=0x0, OS=0x40004, fileType=0x1, subtype=0x0, date=(0, 0) ), kids=[ StringFileInfo( [ StringTable( u'040904b0', [StringStruct(u'CompanyName', u'Your Company'), StringStruct(u'FileDescription', u'Auto Resign Tool'), StringStruct(u'FileVersion', u'1.0.3'), StringStruct(u'InternalName', u'autoResign_exe'), StringStruct(u'LegalCopyright', u'© 2025 Your Company'), StringStruct(u'OriginalFilename', u'autoResign_exe.exe'), StringStruct(u'ProductName', u'Auto Resigner'), StringStruct(u'ProductVersion', u'1.0.0')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) ] ) """ if __name__ == "__main__": package_project() 打包的exe无法在无python环境的电脑上运行,请帮忙修复
最新发布
11-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值