Tencent/tinker · critical · TinkerRuntimeException
createInlineFence failed
Error message
createInlineFence failed
What it means
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.
Source
Thrown at tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java:158
long applicationStartMillisTime,
Intent resultIntent) {
try {
// Use reflection to create the delegate so it doesn't need to go into the primary dex.
// And we can also patch it
final Class<?> delegateClass = Class.forName(delegateClassName, false, mCurrentClassLoader);
final Constructor<?> constructor = delegateClass.getConstructor(Application.class, int.class, boolean.class,
long.class, long.class, Intent.class);
final Object appLike = constructor.newInstance(app, tinkerFlags, tinkerLoadVerifyFlag,
applicationStartElapsedTime, applicationStartMillisTime, resultIntent);
final Class<?> inlineFenceClass = Class.forName(
"com.tencent.tinker.entry.TinkerApplicationInlineFence", false, mCurrentClassLoader);
final Class<?> appLikeClass = Class.forName(
"com.tencent.tinker.entry.ApplicationLike", false, mCurrentClassLoader);
final Constructor<?> inlineFenceCtor = inlineFenceClass.getConstructor(appLikeClass);
inlineFenceCtor.setAccessible(true);
return (Handler) inlineFenceCtor.newInstance(appLike);
} catch (Throwable thr) {
throw new TinkerRuntimeException("createInlineFence failed", thr);
}
}
protected void onBaseContextAttached(Context base, long applicationStartElapsedTime, long applicationStartMillisTime) {
try {
loadTinker();
mCurrentClassLoader = base.getClassLoader();
mInlineFence = createInlineFence(this, tinkerFlags, delegateClassName,
tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime,
tinkerResultIntent);
TinkerInlineFenceAction.callOnBaseContextAttached(mInlineFence, base);
//reset save mode
if (useSafeMode) {
ShareTinkerInternals.setSafeModeCount(this, 0);
}
} catch (TinkerRuntimeException e) {
throw e;
} catch (Throwable thr) {View on GitHub (pinned to 1b7ea02c23)
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.
Example fix
# proguard-rules.pro (before: no rules, classes stripped)
# after:
-keep class com.tencent.tinker.** { *; }
-dontwarn com.tencent.tinker.** Defensive patterns
Strategy: try-catch
Validate before calling
// Build-time guard: verify classes survive minification // ./gradlew task output or apkanalyzer to confirm // com.tencent.tinker.entry.TinkerApplicationInlineFence exists in the APK
Try / catch
try {
mInlineFence = createInlineFence(...);
} catch (TinkerRuntimeException e) {
// entry classes missing: fail fast with actionable message about keep rules
throw new IllegalStateException("Tinker entry classes stripped — add proguard keeps", e);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- createDelegate failed
- Cannot query transaction code of performDexOptSecondary.
- resource references is null
- Fail to hack resourceImpls field.
- failed to fetch instance of ActivityThread.
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/dbfd6bcda50ef2a9.
Report an issue: GitHub.