Encrypt your code through the Advanced Protection.
Please ensure that the following programs are installed prior to proceeding with this tutorial.
- Unity Installed: version 4.6 or later
- Android SDK Installed: API 8 or later / Android SDK build-tools revision 19.1 or later
- JAVA JDK
- AppSealing Unity Extension
It is recommended that you try implementing AppSealing with a sample project before continuing to your own project.
2.2 Import project to Unity
- Launch Unity
- Click the ‘Open’ button
- Select the project folder and import to Unity.
- When the project has been completely imported, Assets are created in the Unity.
2.3 Install AppSealing Unity Extension
- Download the Unity Extension.
- Download link: AppSealing Unity Extension
- Path: ‘Assets’ menu > ‘Import Package’ > Click the ‘Custom Package’
3. AppSealing Tagging
3.1 Start AppSealing
- Click the ‘Create AppSealing Attribute Class’ to start AppSealing. (Fig.1)
- Path: ‘AppSealing’ menu > Click the ‘Create Attribute Class’
3.2 AppSealing Tagging
AppSealing tagging (declaring attribute) needs to be done to the code in order for protection. In this tutorial tagging means declaring the attribute. There are three types of tag that can be added to protect the code. The following steps will instruct on how to add each tags to the code by different situations.
3.2.1 Class Protection
Declare [AppSealingSecurityClass] attribute in each class that you wish to protect. Use this to protect the whole class. Please take reference of the attribute declared on (Fig. 3).
3.2.2 Method Protection
Declare [AppSealingSecurityMethod] attribute in each method that you wish to protect. Use this if you wish to protect a certain method, but not the class. Please take reference of the attribute declared on (Fig. 4).
3.2.3 Exclude Specific Method from Protection
Declare [AppSealingSecurityNotApply] attribute in each method to exclude from protection. Use this to allow better app performance. Please take reference of the attribute declared on (Fig. 5).
3.3 Important Guideline
- It is highly recommended that the attribute is declared in the Awake or Start method of the first Scene.
- Inner classes and methods needs to be tagged additionally in order to protect them.
- Using C# name obfuscation can cause compatibility issue with AppSealing.
- Encrypting Assembly-CSharp.dll file will cause Sealing to fail.
- The following methods are not encrypted by AppSealing, please move the important code to a separate method and call the method.
- Coroutine method
- Anonymous method and lamda expression
- Method using lock or System.Threading.Monitor
- Abstract class
- For optimal performance, it is recommended that the following methods are excluded from protection:
- Update method of Scene or other methods called from Update
- 3rd party methods (ex. Google Play Login, Facebook, Twitter etc...)
- Methods that are called frequently during execution
NOTE: The game must run properly on Unity after tagging has been done. If the game does not run then check the tagging or the game logic.
- Click the play button on Unity. (Fig. 6)
- Proceed to next step if the game runs properly.
3.4 Build APK File
- Use the build function in Unity to build the APK file of the project.
- Path: Ctrl+Shift+B or ‘File’ > Click ‘Build Settings…’
4. Sealing APK
Sealing on the APK is required to activate the security module. Please upload the APK file on the Developer Console page.
Sealing Tutorial Link : Sealing Tutorial