Troubleshoot Hotfix patch tool errors

Updated at:

To troubleshoot errors in the Hotfix patch tool:

  • If you encounter an issue, you can search the FAQ page for keywords.

  • To use the tool, you must install a Java environment with JDK 7 or a later version and uninstall any versions of JDK 6 or earlier. If you use a Windows system, you must also delete the `java.exe`, `javaw.exe`, and `javaws.exe` files from the `C:\Windows\System32` and `C:\Windows\SysWOW64` folders. Note: Configure the environment variables as you would for an Android development environment. If you are configuring environment variables for the first time, you must restart your computer. You can download the Java installation package from the official website.

  • If the Mac version crashes on startup, you can move the patch tool to the Applications folder.

  • If you receive a `no patchClasses` error when you generate a patch, it is because Instant Run was enabled during APK packaging. This feature changes the internal structure of the APK and prevents the tool from finding differences between the old and new packages. To fix this issue, disable Instant Run, regenerate both the old and new packages, and then create and apply the patch again.

  • If an error about no resource differences occurs when you generate a patch, and you have not changed any resources or .so files, you can select the option to skip comparing resources or .so files. Then, generate the patch again.

  • If you use an application reinforcement tool, you must run the patch tool before you reinforce the application.

  • If the patch tool crashes while you generate a patch, it may be because you changed a part of the project that cannot be modified, such as the AndroidManifest file. For more information about supported fixes, see Does Sophix support fixes for any code and resources?.

  • The initialization check feature was added in version 3.2.1 of the tool.

    • For quick integration, you can place the `initialize` call in the `attachBaseContext` method of the `Application` class that is registered in the manifest.

    • If you use MultiDex, you must call `MultiDex.install(this)` before you call `initialize`.

    • Do not place the `queryAndLoadNewPatch` method in `attachBaseContext`.

    • For both quick and robust integration, do not call any non-system Android API classes before the `initialize` call.

    • If you use MultiDex and enable obfuscation, you must add the following rules to your configuration file:

      // For the support library
      -keep class android.support.multidex.**{*;}
      // For the AndroidX library
      -keep class androidx.multidex.**{*;}
    • If you use Kotlin, you must write the `Application` class that contains the hotpatching initialization code in Java. This is because Kotlin automatically calls another class first.

    • If another plugin inserts code before the initialization, you must configure that plugin to not inject code into the `Application` class where the initialization occurs.

    • The tool cannot determine the specific class name for an anonymous inner class. If the tool detects one, you must confirm that `SophixStubApplication` does not use any non-system APIs. After you confirm this, you can clear the initialization check option.

  • Keep the `Application` class that contains the initialization code identical in both the old and new packages. Do not make any changes to it.

  • If you enable resource obfuscation using ResGuard, you must add a rule to prevent the XML resources in the `res/raw` and `res/mipmap` folders from being obfuscated.

  • If you receive a 'dex not supported' error, you can set `minSdkVersion` to a value from 15 to 21. Then, regenerate the old and new packages and create the patch.

  • If you use a Windows 10 system and the errors persist after you try the previous steps, you can change the program's compatibility settings or run it as an administrator.

    Generate a patch.

If the steps above do not resolve the issue, you can contact Technical Support for assistance.