PageFactory with Custom MobileElement - No SuchMethodError error

Hi,

I created a class named MobileElement which extends AndroidElement, placed the class under the package “io.appium.helper” and used PageFactory to initialise elements in a page class.

Sample page class:

public LoginPage() {
	initElements(this);
}

@AndroidFindBy(id="d/username")
private Mobileelement txtUsername;

@AndroidFindBy(id="id/user_password")
private Mobileelement txtPassword;

@AndroidFindBy(name="Login")
private Mobileelement btnLogin;

below method is called from page class.
public void initElements(MobilePage page){
PageFactory.initElements(new AppiumFieldDecorator(driver), page);
}

this used to work well, but when i restructured my project, i found this to be failing. pasting the stacktrace below. Unable to figure out what went wrong. Can anyone help me on this.

net.sf.cglib.core.CodeGenerationException: java.lang.NoSuchMethodException–>io.appium.helper.Mobileelement$$EnhancerByCGLIB$$4d034eee.init()
at net.sf.cglib.core.ReflectUtils.getConstructor(ReflectUtils.java:248)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:604)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:532)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:300)
at io.appium.java_client.pagefactory.ProxyFactory.getEnhancedProxy(ProxyFactory.java:22)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForLocator(AppiumFieldDecorator.java:125)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:73)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:115)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:107)
at io.appium.helper.MobilePage.initElements(MobilePage.java:34)
at fk.sp.mobile.automation.pagemodels.LoginPage.(LoginPage.java:18)
at fk.sp.mobile.automation.api.tests.SellerMobileLoginTests.validateLoginWithValidCredentials(SellerMobileLoginTests.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodException: io.appium.helper.Mobileelement$$EnhancerByCGLIB$$4d034eee.()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at net.sf.cglib.core.ReflectUtils.getConstructor(ReflectUtils.java:244)
… 27 more

Code is for Native app and am using java client 2.0.0