{"record":{"id":"e9da3b069cef7cde","repo":"Tencent/tinker","slug":"createdelegate-failed","errorCode":null,"errorMessage":"createDelegate failed","messagePattern":"createDelegate failed","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"critical","filePath":"tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java","lineNumber":102,"sourceCode":"    }\n\n    private ApplicationLike createDelegate(Application app,\n                                           int tinkerFlags,\n                                           String delegateClassName,\n                                           boolean tinkerLoadVerifyFlag,\n                                           long applicationStartElapsedTime,\n                                           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            return (ApplicationLike) constructor.newInstance(app, tinkerFlags, tinkerLoadVerifyFlag,\n                    applicationStartElapsedTime, applicationStartMillisTime, resultIntent);\n        } catch (Throwable thr) {\n            throw new TinkerRuntimeException(\"createDelegate failed\", thr);\n        }\n    }\n\n    protected void onBaseContextAttached(Context base, long applicationStartElapsedTime, long applicationStartMillisTime) {\n        try {\n            mCurrentClassLoader = base.getClassLoader();\n            this.tinkerResultIntent = new Intent();\n            ShareIntentUtil.setIntentReturnCode(this.tinkerResultIntent, ShareConstants.ERROR_LOAD_DISABLE);\n            mAppLike = createDelegate(this, tinkerFlags, delegateClassName,\n                    tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime,\n                    tinkerResultIntent);\n            mAppLike.onBaseContextAttached(base);\n        } catch (TinkerRuntimeException e) {\n            throw e;\n        } catch (Throwable thr) {\n            throw new TinkerRuntimeException(thr.getMessage(), thr);\n        }\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java#L84-L120","documentation":"TinkerApplication.createDelegate reflectively loads the ApplicationLike delegate class (Class.forName with the app's classloader), locates its (Application, int, boolean, long, long, Intent) constructor and instantiates it. Any failure — class not found, no such constructor, instantiation error — is wrapped in TinkerRuntimeException('createDelegate failed', thr). The delegate is generated by the tinker gradle plugin, so a mismatch between the configured delegate class name and what the build actually produced is the classic trigger.","triggerScenarios":"Class.forName(delegateClassName) fails (delegate class absent from the base dex), getConstructor fails (signature changed across tinker versions), or newInstance throws (delegate constructor exception). Typical with an incorrect tinkerOldApk/apply mapping, obfuscated builds where the generated delegate was renamed, or a tinker loader/library version combination with different constructor signatures.","commonSituations":"Upgrading tinker runtime but keeping an old patch/base mixing component versions; enabling proguard without keeping the generated ApplicationLike subclass; manually editing the delegate class name in build.gradle; multidex config that moves the delegate out of the primary dex on some devices.","solutions":["Check the cause inside the TinkerRuntimeException: ClassNotFoundException => the delegate class name from the gradle config is wrong or was obfuscated away; NoSuchMethodException => tinker component version mismatch.","Use matching versions of tinker-android-lib, tinker-android-loader and the gradle plugin in one build.","Add proguard keep rules for your ApplicationLike subclass (e.g. -keep public class * extends com.tencent.tinker.loader.app.ApplicationLike).","Verify the manifest/gradle delegate class name matches the generated class (build/intermediates/tinker/...)."],"exampleFix":"# proguard-rules.pro\n# before: delegate obfuscated -> createDelegate failed at runtime\n# after: keep the generated ApplicationLike\n-keep public class * extends com.tencent.tinker.loader.app.ApplicationLike {\n    public <init>(android.app.Application, int, boolean, long, long, android.content.Intent);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    appLike = createDelegate(...);\n} catch (TinkerRuntimeException e) {\n    Throwable cause = e.getCause();\n    // ClassNotFoundException -> wrong/obfuscated delegate name\n    // NoSuchMethodException -> tinker version mismatch\n    logOrReport(cause);\n}","preventionTips":["Pin tinker lib, loader and plugin to one version","Keep the generated ApplicationLike subclass and its constructor from proguard","Verify the delegate class exists in the primary dex of the base APK"],"tags":["tinker","android","reflection","proguard","version-mismatch"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}