Fix duplicate declare when cache fails (#59)

This commit is contained in:
LoveSy 2021-02-03 19:34:08 +08:00 committed by GitHub
parent 72b3dcde97
commit 68bb2d3db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -135,13 +135,13 @@ public class HookerDexMaker {
@SuppressWarnings("ResultOfMethodCallIgnored")
@TargetApi(Build.VERSION_CODES.O)
private void doMake(String hookedClassName) throws Exception {
mDexMaker = new DexMaker();
ClassLoader loader = null;
// Generate a Hooker class.
String className = CLASS_NAME_PREFIX;
boolean usedCache = false;
if (canCache) {
try {
mDexMaker = new DexMaker();
// className is also used as dex file name
// so it should be different from each other
String suffix = DexMakerUtils.getSha1Hex(mMember.toString());
@ -165,8 +165,9 @@ public class HookerDexMaker {
if (!usedCache) {
// do everything in memory
DexLog.d("Generating in memory");
if(BuildConfig.DEBUG)
if (BuildConfig.DEBUG)
className = className + hookedClassName.replace(".", "/");
mDexMaker = new DexMaker();
doGenerate(className);
byte[] dexBytes = mDexMaker.generate();
loader = new InMemoryDexClassLoader(ByteBuffer.wrap(dexBytes), mAppClassLoader);