Fix duplicate declare when cache fails (#59)
This commit is contained in:
parent
72b3dcde97
commit
68bb2d3db7
|
|
@ -135,13 +135,13 @@ public class HookerDexMaker {
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
private void doMake(String hookedClassName) throws Exception {
|
private void doMake(String hookedClassName) throws Exception {
|
||||||
mDexMaker = new DexMaker();
|
|
||||||
ClassLoader loader = null;
|
ClassLoader loader = null;
|
||||||
// Generate a Hooker class.
|
// Generate a Hooker class.
|
||||||
String className = CLASS_NAME_PREFIX;
|
String className = CLASS_NAME_PREFIX;
|
||||||
boolean usedCache = false;
|
boolean usedCache = false;
|
||||||
if (canCache) {
|
if (canCache) {
|
||||||
try {
|
try {
|
||||||
|
mDexMaker = new DexMaker();
|
||||||
// className is also used as dex file name
|
// className is also used as dex file name
|
||||||
// so it should be different from each other
|
// so it should be different from each other
|
||||||
String suffix = DexMakerUtils.getSha1Hex(mMember.toString());
|
String suffix = DexMakerUtils.getSha1Hex(mMember.toString());
|
||||||
|
|
@ -165,8 +165,9 @@ public class HookerDexMaker {
|
||||||
if (!usedCache) {
|
if (!usedCache) {
|
||||||
// do everything in memory
|
// do everything in memory
|
||||||
DexLog.d("Generating in memory");
|
DexLog.d("Generating in memory");
|
||||||
if(BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
className = className + hookedClassName.replace(".", "/");
|
className = className + hookedClassName.replace(".", "/");
|
||||||
|
mDexMaker = new DexMaker();
|
||||||
doGenerate(className);
|
doGenerate(className);
|
||||||
byte[] dexBytes = mDexMaker.generate();
|
byte[] dexBytes = mDexMaker.generate();
|
||||||
loader = new InMemoryDexClassLoader(ByteBuffer.wrap(dexBytes), mAppClassLoader);
|
loader = new InMemoryDexClassLoader(ByteBuffer.wrap(dexBytes), mAppClassLoader);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue