{"record":{"id":"dbfd6bcda50ef2a9","repo":"Tencent/tinker","slug":"createinlinefence-failed","errorCode":null,"errorMessage":"createInlineFence failed","messagePattern":"createInlineFence failed","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"critical","filePath":"tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java","lineNumber":158,"sourceCode":"                                      long applicationStartMillisTime,\n                                      Intent resultIntent) {\n        try {\n            // Use reflection to create the delegate so it doesn't need to go into the primary dex.\n            // And we can also patch it\n            final Class<?> delegateClass = Class.forName(delegateClassName, false, mCurrentClassLoader);\n            final Constructor<?> constructor = delegateClass.getConstructor(Application.class, int.class, boolean.class,\n                    long.class, long.class, Intent.class);\n            final Object appLike = constructor.newInstance(app, tinkerFlags, tinkerLoadVerifyFlag,\n                    applicationStartElapsedTime, applicationStartMillisTime, resultIntent);\n            final Class<?> inlineFenceClass = Class.forName(\n                    \"com.tencent.tinker.entry.TinkerApplicationInlineFence\", false, mCurrentClassLoader);\n            final Class<?> appLikeClass = Class.forName(\n                    \"com.tencent.tinker.entry.ApplicationLike\", false, mCurrentClassLoader);\n            final Constructor<?> inlineFenceCtor = inlineFenceClass.getConstructor(appLikeClass);\n            inlineFenceCtor.setAccessible(true);\n            return (Handler) inlineFenceCtor.newInstance(appLike);\n        } catch (Throwable thr) {\n            throw new TinkerRuntimeException(\"createInlineFence failed\", thr);\n        }\n    }\n\n    protected void onBaseContextAttached(Context base, long applicationStartElapsedTime, long applicationStartMillisTime) {\n        try {\n            loadTinker();\n            mCurrentClassLoader = base.getClassLoader();\n            mInlineFence = createInlineFence(this, tinkerFlags, delegateClassName,\n                    tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime,\n                    tinkerResultIntent);\n            TinkerInlineFenceAction.callOnBaseContextAttached(mInlineFence, base);\n            //reset save mode\n            if (useSafeMode) {\n                ShareTinkerInternals.setSafeModeCount(this, 0);\n            }\n        } catch (TinkerRuntimeException e) {\n            throw e;\n        } catch (Throwable thr) {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java#L140-L176","documentation":"TinkerApplication.createInlineFence reflectively constructs com.tencent.tinker.entry.TinkerApplicationInlineFence wrapping an ApplicationLike delegate; the resulting Handler is the 'inline fence' that forwards Application lifecycle into the patched application. TinkerRuntimeException('createInlineFence failed') wraps any failure in that reflection chain.","triggerScenarios":"Class.forName on TinkerApplicationInlineFence or ApplicationLike failing (classes stripped by minification or absent because the tinker-android-loader entry jar was not kept), constructor lookup/newInstance failing, or the classes visible to a different ClassLoader than mCurrentClassLoader.","commonSituations":"Missing ProGuard keep rules for com.tencent.tinker.**; tinker-android-loader / entry components packaged incorrectly; app using a custom loader/entry class name mismatch with what the patch carries.","solutions":["Add ProGuard/R8 keep rules for the Tinker entry and loader classes (e.g. -keep class com.tencent.tinker.** { *; }).","Verify tinker-android-loader is on the classpath and its version matches the gradle plugin that builds patches.","If using a custom loaderClassName/delegateClassName, confirm both classes exist and their constructors match the expected signatures."],"exampleFix":"# proguard-rules.pro (before: no rules, classes stripped)\n# after:\n-keep class com.tencent.tinker.** { *; }\n-dontwarn com.tencent.tinker.**","handlingStrategy":"try-catch","validationCode":"// Build-time guard: verify classes survive minification\n// ./gradlew task output or apkanalyzer to confirm\n// com.tencent.tinker.entry.TinkerApplicationInlineFence exists in the APK","typeGuard":null,"tryCatchPattern":"try {\n    mInlineFence = createInlineFence(...);\n} catch (TinkerRuntimeException e) {\n    // entry classes missing: fail fast with actionable message about keep rules\n    throw new IllegalStateException(\"Tinker entry classes stripped — add proguard keeps\", e);\n}","preventionTips":["Add -keep class com.tencent.tinker.** { *; } to proguard rules.","Run a smoke test on minified release builds before shipping.","Keep tinker-android-loader, gradle plugin, and entry artifacts version-aligned."],"tags":["android","reflection","proguard","classloader","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}