I wrote a hot updated demo by hand, friends who are interested can go and have a look
https://gitee.com/iblue007/SmartPluginableHotFixhttps://gitee.com/iblue007/SmartPluginableHotFix
During hot update, you need to generate the dex file by yourself. Here, you need to convert the .java file into a .class file, and then convert the .class file into a .dex file. The steps are as follows:
Click Build --> Rebuild project. After clicking, the class files that need to be packaged into jar will be displayed in the directory shown below. It points out the class files that we need to package. The generated class files are in app/build/intermediates/Javac middle
.class to generate dex needs to use the dx.bat supported by androidstudio, we find the android SDK directory
build-tools file directory.
Open cmd and run the command to enter the folder path:
dx --dex --output Save the path after generating dex and the directory where the dex name class file is located
For example: I generate a dex file to be saved in the project's build/patch file directory, and the class is stored in app/build/intermediates/Javac when it was compiled before
At this time, a does not match path error was reported . In fact, the path directory is correct. But the compiler just can't pass it.
At this time, just add --no-strict after --dex.
Make compiler monitoring less strict.
As follows: dx --dex --no-strict --output
The compilation is passed, the dex file is successfully generated, and it is smoked, hahahaha