0
I have an implementation made with Socket.IO on android. However after I update the android studio, everything stopped working...
I created routines to facilitate lib implementation, one of them is an Annotation @IOXEvent
.
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface IOXEvent {
String value();
}
To make use of this Annotation, I informed the name of the event I would like to hear in the class, as example below:
IOXEvent("mensagem:nova")
public void aoReceberMensagem(String mensagem) {
Log.i("TESTE", mensagem)
}
It turns out that the class aoReceberMensagem
is not used by the code of my app, so it turns gray as if there was no reference to it. Then when using the routine below, the method name comes as "Wait" and the variable ann
comes as null
.
public void attach(final Object o) {
Class c = o.getClass();
for (final Method m : c.getMethods()) {
IOXEvent ann = m.getAnnotation(IOXEvent.class);
if(ann != null && !ann.value().equals("")) {
this.sdd.off(ann.value());
this.on(ann.value(), new IOXListener() {
@Override
public void call(Object... args) {
try {
m.invoke(o, args);
} catch (Exception ex) {
Log.e("IOX_ERROR", ex.toString());
}
}
});
}
}
}
I believe that somehow the unused methods are being removed in the build of the app even in debug. Does anyone know how I can fix this?
i think the methods that are not used(called) in the application do not work
– Gabriel Aguiar
Then @Gabrielaguiar but before it worked... The problem started to occur after gave update Android Studio. It is called via Reflection, based on the string of Annotation.
– Hiago Souza