- 反编译APK文件
- 修改文件目录中的AndroidManifest.xml文件,在
标签中添加android:debuggable="true"属性 - 回编apk,对齐align,重签名
- 运行app
- 执行
adb shell run-as <package_name> cat shared_prefs/<package_name>.v2.playerprefs.xml
shell
shell学习
在MacOS中的Shell脚本执行sed -i命令报错
MacOS sed -i命令报错
需要删除test.txt中的所有hello world
字符串,命令如下,
sed -i '/hello world/d' test.txt
但执行时会报错,报错信息如下:
sed: 1: "test.txt": undefined label 'est.txt'
原因:
Mac中用-i命令进行替换时,强制要求备份,-i要加一个备份文件路径的参数
sed -i 'copypath' '/hello world/d' test.txt
如果不想备份,路径填空就行
sed -i '' '/hello world/d' test.txt
How to decode cmd output correctly?
ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe");
startInfo.Arguments = "/c " + URL;
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
p = Process.Start(startInfo);
string xxx = p.StandardOutput.ReadToEnd();
获得标准输出的正确结果,需要增加以下代码
startInfo.StandardOutputEncoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage)
在苹果OSX系统下,使用jenkins shell时判断Unity是否在运行的方法
打包时,如果打包机(苹果OSX系统)的Unity正在运行,则会打包失败。为了尽早捕获这种异常,需要判定Unity是否在运行。
经过一番搜索,还是使用了最原始的判断进程关键字的方法。Unity在mac上运行时,ps 查看进程通常有/xx/xx/Unity -projectPath xxx
特征,提取最精简部分,统计进程数量(wc -l输出行数),即可。使用如下方式进行判定,目前准确率还行,用一段时间试试看。
#!/bin/bash
if [ $(ps -ef | grep "Unity -projectPath" | wc -l) = "2" ]; then
echo "The Unity instance is running, exit now!"
exit 1
fi
关于bash:在sed命令中转义正斜杠
- 如果replace内容不包含
/
这种写法没问题sed"s/regex/replace/" file
- 如果replace内容包含
/
,则改变分割符号为|
,完整写法为sed"s|regex|replace|" file
,这样就不用为\
写转义了