我为我的图书馆启用了Proguard。
在我的图书馆里,我有一个名为Hard的课程。
然后我在我的APP中使用这个库。然后我尝试将其称为Library Class Hard,它的方法是使用Reflection调用onOrientationChange()。
Class noParams[] = {};
Class[] paramContext = new Class[1];
paramContext[0] = Context.class;
Class[] paramActivity = new Class[1];
paramActivity[0] = Activity.class;
Class push = null;
try {
push = Class.forName("com.test.example.Hard");
if (null != push) {
Constructor constructor = push.getDeclaredConstructor();
Object clazz = constructor.newInstance();
Method enteringActivity = clazz.getClass().getDeclaredMethod("onOrientationChange", paramActivity);
enteringActivity.invoke(clazz, activity);
}
} catch (ClassNotFoundException e1) {
Log.w(Util.TAG, "method Orientation is not present");
} catch (IllegalAccessException e1) {
e1.printStackTrace();
} catch (NoSuchMethodException e1) {
e1.printStackTrace();
} catch (InvocationTargetException e1) {
e1.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
但是当我尝试在我的空白App中使用库时,我得到No such Method Exception Error。
java.lang.NoSuchMethodException:onOrientationChange [class android.app.Activity]
这是我的库类及其方法。 package com.test.example;
public class Hard extends TelephoneBase implements WidgetClickListener, Constants {
public void onOrientationChange(Activity activity) {
TestExample(activity);
}
}
这是Proguard.pro文件
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
-keep class class com.test.example.Hard { *; }
-keepclassmembers class com.test.example.Hard { *; }
-dontpreverify
-dontoptimize
-dontshrink
有人可以告诉我我做错了什么吗?