user3313487
user3313487

Reputation: 1

Android Class.forName from library class

I need to create an Object using Class.forName("classname").newInstance() where classname is a class inside a library correctly imported into my app, but it's not working (classNotFoundException).

I tried by setting classname = path (i.e. /Project/src/package/Class) but it's not working either.

How do I reference the class? It works if the class is inside my project so I guess it's because it's inside a library.

Thanks in advance!!

Upvotes: 0

Views: 473

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007399

How do I reference the class?

By its fully.qualified.class.name.IncludingThePackage.

Note that you may need to teach ProGuard not to obfuscate the name of this class for your release builds.

Upvotes: 1

Related Questions