I am working from package name com.thinktube.adhocconfigdemo
Current class is AdHocConfigActivity which contains methods setStaticIpConfiguration.
The error while running app is as below.
com.thinktube.adhocconfigdemo W/System.err: java.lang.NoSuchMethodException: setIpAssignment [class android.net.IpConfiguration$IpAssignment]
com.thinktube.adhocconfigdemo W/System.err: at java.lang.Class.getMethod(Class.java:664)
com.thinktube.adhocconfigdemo W/System.err: at java.lang.Class.getDeclaredMethod(Class.java:626)
com.thinktube.adhocconfigdemo W/System.err: at com.thinktube.adhocconfigdemo.AdhocConfigActivity.callMethod(AdhocConfigActivity.java:213)
com.thinktube.adhocconfigdemo W/System.err: at com.thinktube.adhocconfigdemo.AdhocConfigActivity.setStaticIpConfiguration(AdhocConfigActivity.java:155
Here, 155th line of SetStaticIpConfigurationMethod is:
callMethod(config, "setIpAssignment", new String[] { "android.net.IpConfiguration$IpAssignment" }, new Object[] { ipAssignment });
and 213 line in my code is:
Method method = object.getClass().getDeclaredMethod(methodName, parameterClasses);
in callMethod method.
where callMethod is as below:
private static void callMethod(Object object, String methodName, String[] parameterTypes, Object[] parameterValues) throws ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException
{
Class<?>[] parameterClasses = new Class<?>[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++)
parameterClasses[i] = Class.forName(parameterTypes[i]);
Log.i("AdHocAct", parameterClasses[0].isEnum()+"");
Log.i("AdHocAct", parameterClasses[0].getName());
Log.i("AdHocAct", object.getClass().getName());
Method method = object.getClass().getDeclaredMethod(methodName, parameterClasses);
method.invoke(object, parameterValues);
}
Here, config object used to call callMethod method is of type WifiConfigurationNew class which extends WifiConfiguration class.
Logs printed in callMethod method are as below
com.thinktube.adhocconfigdemo I/AdHocAct: true
com.thinktube.adhocconfigdemo I/AdHocAct: android.net.IpConfiguration$IpAssignment
com.thinktube.adhocconfigdemo I/AdHocAct: com.thinktube.adhocconfigdemo.WifiConfigurationNew
My question is what is meaning of the error?
Is it says that method setIpAssignment with parameter type [class android.net.IpConfiguration$IpAssignment] does not exist?
Because, such a method is present in WifiConfiguration class. As below,
public void setIpAssignment(IpConfiguration.IpAssignment ipAssignment) {
mIpConfiguration.ipAssignment = ipAssignment;
}
Aucun commentaire:
Enregistrer un commentaire