mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 09:02:50 +08:00
deprecate: CoreAndroid.getBuildConfigValue (#1597)
This commit is contained in:
parent
2252c09a49
commit
5b546a27e6
@ -19,6 +19,8 @@
|
||||
|
||||
package org.apache.cordova;
|
||||
|
||||
import org.apache.cordova.BuildHelper;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -30,7 +32,6 @@ import android.content.IntentFilter;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@ -383,28 +384,12 @@ public class CoreAndroid extends CordovaPlugin {
|
||||
* Thanks to Phil@Medtronic and Graham Borland for finding the answer and posting it to
|
||||
* StackOverflow. This is annoying as hell!
|
||||
*
|
||||
* @deprecated Use {@link BuildHelper#getBuildConfigValue} instead.
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public static Object getBuildConfigValue(Context ctx, String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = Class.forName(ctx.getClass().getPackage().getName() + ".BuildConfig");
|
||||
Field field = clazz.getField(key);
|
||||
return field.get(null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOG.d(TAG, "Unable to get the BuildConfig, is this built with ANT?");
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
LOG.d(TAG, key + " is not a valid field. Check your build.gradle");
|
||||
} catch (IllegalAccessException e) {
|
||||
LOG.d(TAG, "Illegal Access Exception: Let's print a stack trace.");
|
||||
e.printStackTrace();
|
||||
} catch (NullPointerException e) {
|
||||
LOG.d(TAG, "Null Pointer Exception: Let's print a stack trace.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
LOG.w(TAG, "CoreAndroid.getBuildConfigValue is deprecated and will be removed in a future release. Use BuildHelper.getBuildConfigValue instead.");
|
||||
return BuildHelper.getBuildConfigValue(ctx, key);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user