假设我有一个uiautomator JAR文件,我的应用程序将调用/运行uiautomator JAR文件。我如何将其打包到我的应用程序的APK中,以便在我通过运行APK安装我的应用程序时将JAR部署到手机中的特定文件夹?
答案 0 :(得分:0)
对于有兴趣知道的人,我通过将我的脚本JAR附加到APK中的资产文件夹来解决它,并使用下面的代码在我想要的地方重新创建文件。
InputStream tempIn = assetMgr.open("UiautomationScript.jar");
int size = tempIn.available();
byte[] buffer = new byte[size];
tempIn.read(buffer);
FileOutputStream(Environment.getExternalStorageDirectory().getPath() + "/UiautomationScript.jar");
OutputStream tempOut = new FileOutputStream("/data/local/tmp/UiautomationScript.jar");
tempOut.write(buffer, 0, size);
tempIn.close();