<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
Hi everyone</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
My name is Diyu Wu and I am currently working on a project leveraging FlowDroid.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
I try to leverage the callgraph built by FlowDroid 2.7.1 and perform some instrumentation on an Android apk file.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
the genaral code snippet look like this.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102)">
<span style="margin: 0px">public static void main(String[] args){</span>
<div style="margin: 0px"> SetupApplication app = new SetupApplication("/home/derekwu/Current/android.jar", apkfile);<br>
</div>
<div style="margin: 0px"> app.constructCallgraph();<br>
</div>
<div style="margin: 0px"> <br>
</div>
<div style="margin: 0px"> instrument();</div>
<div style="margin: 0px"> </div>
<div style="margin: 0px"> generateInstrumentedApk(apkfile)</div>
<div style="margin: 0px"> jarsigner();<br>
</div>
<div style="margin: 0px"> zipalign(); </div>
<span style="margin: 0px">}</span><br>
</blockquote>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)">
<span style="margin: 0px">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102)">
<span style="margin: 0px">private static void<span> </span><span style="margin: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important"><span style="margin: 0px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255); display: inline !important">generateInstrumentedApk</span></span>(String
apkfile){<br>
</span>
<div style="margin: 0px"> final DexPrinter dexPrinter = new DexPrinter();<br>
</div>
<div style="margin: 0px"> try{<br>
</div>
<div style="margin: 0px"> int threadNum = Runtime.getRuntime().availableProcessors();<br>
</div>
<div style="margin: 0px"> <span> </span><br>
</div>
<div style="margin: 0px"> CountingThreadPoolExecutor executor = new CountingThreadPoolExecutor(threadNum, threadNum, 30, TimeUnit.SECONDS,<br>
</div>
<div style="margin: 0px"> new LinkedBlockingQueue<Runnable>());<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> Iterator<SootClass> classIterator = Scene.v().getApplicationClasses().snapshotIterator();<br>
</div>
<div style="margin: 0px"> while(classIterator.hasNext()){<br>
</div>
<div style="margin: 0px"> final SootClass c = classIterator.next();</div>
<div style="margin: 0px"> executor.execute(new Runnable() {<br>
</div>
<div style="margin: 0px"> <span> </span><br>
</div>
<div style="margin: 0px"> @Override<br>
</div>
<div style="margin: 0px"> public void run() {<br>
</div>
<div style="margin: 0px"> // TODO Auto-generated method stub<br>
</div>
<div style="margin: 0px"> dexPrinter.add(c);<br>
</div>
<div style="margin: 0px"> }<br>
</div>
<div style="margin: 0px"> });<br>
</div>
<div style="margin: 0px"> }<br>
</div>
<div style="margin: 0px"> ...</div>
<div style="margin: 0px"> }<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> finally {<br>
</div>
<div style="margin: 0px"> dexPrinter.print();<br>
</div>
<div style="margin: 0px"> }<br>
</div>
<div style="margin: 0px"> <br>
</div>
<span style="margin: 0px">}</span><br>
</blockquote>
</span></div>
<div style="margin: 0px; font-size: 15px; font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; color: rgb(32, 31, 30); background-color: rgb(255, 255, 255)">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<p style="margin-top: 0px; margin-bottom: 0px">However, this program runs into two problems.</p>
<p style="margin-top: 0px; margin-bottom: 0px"></p>
<ol>
<li>when I try to sign the generated apk file, there is a chance to generate the following excetion. But when I run the program again the exception will disappear.<br>
</li></ol>
<p style="margin-top: 0px; margin-bottom: 0px"></p>
</div>
</div>
<blockquote style="color: rgb(32, 31, 30); font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 15px; background-color: rgb(255, 255, 255); margin: 0px 0px 0px 40px; border: none">
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<p style="margin-top: 0px; margin-bottom: 0px"><span style="margin: 0px">Exception in thread "main" org.jf.util.ExceptionWithContext: Item not found.: [Landroid/text/InputFilter;</span></p>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at org.jf.dexlib2.writer.pool.StringTypeBasePool.getItemIndex(StringTypeBasePool.java:57)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at org.jf.dexlib2.writer.pool.StringTypeBasePool.getItemIndex(StringTypeBasePool.java:43)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at org.jf.dexlib2.writer.DexWriter.writeTypeLists(DexWriter.java:539)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:259)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:246)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at soot.toDex.MultiDexBuilder.writeTo(MultiDexBuilder.java:82)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at soot.toDex.DexPrinter.printApk(DexPrinter.java:269)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at soot.toDex.DexPrinter.print(DexPrinter.java:1512)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<div style="margin: 0px">at clean.CleanProject.instrument(CleanProject.java:98)</div>
</blockquote>
</div>
</div>
<div style="margin: 0px">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 0px">
<p style="margin-top: 0px; margin-bottom: 0px"><span style="margin: 0px">at clean.CleanProject.main(CleanProject.java:48)</span></p>
</blockquote>
</div>
</div>
</blockquote>
<div style="margin: 0px; font-size: 15px; font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; color: rgb(32, 31, 30); background-color: rgb(255, 255, 255)">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<p style="margin-top: 0px; margin-bottom: 0px"></p>
<p style="margin-top: 0px; margin-bottom: 0px"> <span style="margin: 0px">2. for the successfully generated apk files, when I try to install them on a Android emulator(API 21 with 4G RAM), most of the apk files(file size over 1M based on my observation)
coul d not be installed with the INSTALL_FAILED_DEXOPT error. And the logcat shows the following information:</span></p>
<p style="margin-top: 0px; margin-bottom: 0px"><span style="margin: 0px"></span></p>
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102)">
<span style="margin: 0px">09-10 17:53:04.385 9848-9848/? E/dex2oat: Failed to open dex from file descriptor for zip file '/data/app/com.coste.syncorg-1/base.apk': Failure to verify dex file '/data/app/com.coste.syncorg-1/base.apk': Out-of-order string_ids:
'<init>' then '<init>'<br>
</span>
<div style="margin: 0px">09-10 17:53:04.586 9848-9848/? I/dex2oat: dex2oat took 212.207ms (threads: 2)<br>
</div>
<div style="margin: 0px">09-10 17:53:04.588 1159-1159/? E/installd: DexInv: --- END '/data/app/com.coste.syncorg-1/base.apk' --- status=0x0100, process failed<br>
</div>
<div style="margin: 0px">09-10 17:53:04.588 1496-1525/system_process W/PackageManager: Package couldn't be installed in /data/app/com.coste.syncorg-1<br>
</div>
<div style="margin: 0px"> com.android.server.pm.PackageManagerException: scanPackageLI<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService.scanPackageDirtyLI(PackageManagerService.java:5912)<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:5246)<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService.installNewPackageLI(PackageManagerService.java:10077)<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:10585)<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService.access$2300(PackageManagerService.java:233)<br>
</div>
<div style="margin: 0px"> at com.android.server.pm.PackageManagerService$6.run(PackageManagerService.java:8531)<br>
</div>
<div style="margin: 0px"> at android.os.Handler.handleCallback(Handler.java:739)<br>
</div>
<div style="margin: 0px"> at android.os.Handler.dispatchMessage(Handler.java:95)<br>
</div>
<div style="margin: 0px"> at android.os.Looper.loop(Looper.java:135)<br>
</div>
<div style="margin: 0px"> at android.os.HandlerThread.run(HandlerThread.java:61)<br>
</div>
<span style="margin: 0px"> at com.android.server.ServiceThread.run(ServiceThread.java:46)</span><br>
</blockquote>
<p style="margin-top: 0px; margin-bottom: 0px"></p>
</div>
</div>
<div style="margin: 0px; font-size: 15px; font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; color: rgb(32, 31, 30); background-color: rgb(255, 255, 255)">
<div dir="ltr" style="margin: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0)">
<p style="margin-top: 0px; margin-bottom: 0px"></p>
<p style="margin-top: 0px; margin-bottom: 0px">May I ask how can I fix this issue and correctly instrument the apk files?</p>
<p style="margin-top: 0px; margin-bottom: 0px">I look forward to your kind reply.</p>
<p style="margin-top: 0px; margin-bottom: 0px"><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px"><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px">Kind Regards</p>
<p style="margin-top: 0px; margin-bottom: 0px">Diyu Wu</p>
</div>
</div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p style="margin-top: 0px; margin-bottom: 0px;"><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;"><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Kind Regards</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Diyu Wu</p>
</div>
</div>
</body>
</html>