Recently, when doing a project, we need to use the method of reflecting back and forth tone class, but in the reflection process always throws no class found exception in the Class.forName () method, after several checks, problem solving, summarizes the cause of the problem
The class name in the parameter of 1.class.forname () must be the full package name + class name
2. is 1 derivative, in Android Studio, once the package name of the project has been modified, Also need in the auto-generated Build.gradle file (Project Android view) to change the ApplicationID to the modified package name, or install the app after the package name or original, it will cause 1 errors.
The author is 2 card for a long time, finally found a long time to solve, in this record, I hope to help meet this problem friends save time
About the use of the Class.forName () method in Android studio to dynamically get the class instance report no class found exception processing methods