This project is an example of how one could AOT their Android project and IL strip some of their DLLs. Some because this process only seems to work when we're IL stripping platform-independent code.
- Open up the solution (aotstriptest.sln) in Xamarin Studio
- Ensure the configuration is correct. (This should already be configured but just in case):
- Double click on the Android project
- Select "Android Build" from the left panel
- Change the configuration dropdown on the top to say "Release"
- On the general tab make sure everything except for "Enable AOT (Experimental)" is selected. AOT+LLVM does not work
- On the advanced tab, select the ABI's you wish to support. Note that x86_64 is not currently supported.
- Click ok
It should look like this:
- Build and deploy the project for Release
At this point you should see a very simple app in your emulator/device. Click the button on the screen and you should see the text change.
- Go to your terminal and navigate to the project root.
- Run the strip.sh script
Essentially what it does is :
- Unzip the apk
- Strip the platform-independent assembly using mono-cil-strip
- Repackage the apk
- Uninstalls the old apk and reinstalls the new one.
- Launch the app.
At this point you can try and click on the button again and you can see that it is still working.
Lets look at the IL for the unstripped version.
//Assuming you're at the root of the project
$ monodis bin/Release/supersecretlib.dll > unstripped-lib.il
Looking inside we see:
Ok now let's disassemble the stripped version:
$ monodis bin/Release/stripped/assemblies/supersecretlib.dll > stripped-lib.il
Looking inside we see only references to class names and members remain.