I have a fairly large project that uses some reflection in the code. The line of code that is causing the following crash:
W/System.err(22122): java.lang.NoSuchMethodException: <init> [class com.DynaZu.Tracker.cd]
W/System.err(22122): at java.lang.Class.getConstructorOrMethod(Class.java:460)
W/System.err(22122): at java.lang.Class.getDeclaredConstructor(Class.java:588)
W/System.err(22122): at com.DynaZu.Tracker.ItemAdapter.getView(SourceFile:356)
W/System.err(22122): at android.widget.AbsListView.obtainView(AbsListView.java:2267)
Is the SourceFile:356 line:
try {
itemViewHolder = mViewHolderClass.getDeclaredConstructor(item.getClass())
.newInstance(item);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
elsewhere in the file:
Class<? extends ItemViewHolder> mViewHolderClass;
and the item is one of several potential classes all derived from class Item.
When I look into dump.txt, etc... I see lots and lots of stuff I can't quite turn back into a specific directive for proguard.cfg. From dump.txt:
+ Methodref [com/DynaZu/Tracker/cd.<init> (Ljava/lang/String;)V]
+ Methodref [com/DynaZu/Tracker/cd.a ()Ljava/lang/String;]
+ Methodref [com/DynaZu/Tracker/cd.equals (Ljava/lang/Object;)Z]
+ Methodref [com/DynaZu/Tracker/cd.h ()J]
+ Methodref [com/DynaZu/Tracker/cd.o ()Ljava/lang/String;]
+ Methodref [com/DynaZu/Tracker/cd.p ()Lcom/DynaZu/Tracker/cd;]
+ Methodref [com/DynaZu/Tracker/cd.q ()F]
+ Methodref [com/DynaZu/Tracker/ce.a (J)Lcom/DynaZu/Tracker/cd;]
+ Methodref [com/DynaZu/Tracker/ce.a (Lcom/DynaZu/Tracker/cd;)V]
+ InterfaceMethodref [com/DynaZu/Tracker/ac.a (IILcom/DynaZu/Tracker/cd;ZZ)V]
+ NameAndType [<init> (Lcom/DynaZu/Tracker/cd;)V]
+ NameAndType [a (IILcom/DynaZu/Tracker/cd;ZZ)V]
+ NameAndType [a (J)Lcom/DynaZu/Tracker/cd;]
+ NameAndType [a (Lcom/DynaZu/Tracker/cd;)V]
+ NameAndType [a Lcom/DynaZu/Tracker/cd;]
+ NameAndType [b (Lcom/DynaZu/Tracker/cd;I)V]
+ NameAndType [c Lcom/DynaZu/Tracker/cd;]
+ NameAndType [p ()Lcom/DynaZu/Tracker/cd;]
+ Utf8 [()Lcom/DynaZu/Tracker/cd;]
And for proguard.cfg I realize I want something like:
-keepclassmembers class * extends Item
-keep class * extends Item
Any suggestions would be helpful. For example, is there a way to turn of proguard for one java file or one section of this java file???
Looking into this, I believe I need to add something like:
-keepclassmembers class com.DynaZu.Tracker.TaskViewHolder
{
<init>(com.DynaZu.Tracker.Task);
}
etc... BUT ProGuard complains these class are Unknown... ? So how should an existing class in the project be noted in proguard.cfg. ??? I have also tried just the class name TaskViewHolder by itself.