3

I have an Android application.

I want to scan for all classes within a package for a specify annotation.

I have:

package com.sample.package;

import com.sample.core.Controller;
import com.sample.core.ProtocolId;

@Controller
public class OtherController implements ControllerInterface{

    @ProtocolId(id=100)
    public void doSomething(){
        //do something
    }
}

I'm finding for classes annotated with @Controller for a specify @ProtocolId number.

I'm using Google Reflections library.

Here is how I'm scanning:

package com.sample.package;

import org.reflections.ReflectionUtils;
import org.reflections.Reflections;

import com.sample.core.Controller;
import com.sample.core.ProtocolId;

public class FrontController {

    public void executeProperControllerMethodBasedOnId(){
        Reflections ref = new Reflections("com.sample.package");    

        Set<Class<?>> classes = ref.getTypesAnnotatedWith(Controller.class);

        System.out.println(classes.size()); //THE SIZE IS 0!!!
        //The reflection doesn't worked! It didn't found any class!
    }
}

The above code doesn't find any class annotated with specify annotation. Is there something which I miss when I'm using google reflection library on android?

Sorin Vladu
  • 1,768
  • 3
  • 21
  • 37
  • just for referance see this -->http://stackoverflow.com/questions/24697533/manual-proxy-in-android-through-reflection/24797025#24797025 – KOTIOS Aug 05 '14 at 10:19
  • 1
    I have same issue. Did you solve the problem? – Mahdi Nov 10 '18 at 08:34

0 Answers0