From 7efe90faac3219b9991f6a6f622ba7d561b279cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=BF=97=E5=BC=BA?= Date: Fri, 14 Apr 2023 21:15:55 +0800 Subject: [PATCH] fix(BuildHelper): get package name from ApplicationInfo (#1575) --- framework/src/org/apache/cordova/BuildHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/BuildHelper.java b/framework/src/org/apache/cordova/BuildHelper.java index 94fe96120b..2899ee2a00 100644 --- a/framework/src/org/apache/cordova/BuildHelper.java +++ b/framework/src/org/apache/cordova/BuildHelper.java @@ -51,7 +51,8 @@ public static Object getBuildConfigValue(Context ctx, String key) { try { - Class clazz = Class.forName(ctx.getClass().getPackage().getName() + ".BuildConfig"); + String packageName = ctx.getApplicationInfo().packageName; + Class clazz = Class.forName(packageName + ".BuildConfig"); Field field = clazz.getField(key); return field.get(null); } catch (ClassNotFoundException e) {