Validates resource references in Android XML files appear at the Android Studio runtime

Keywords: Java Android xml less

Errors are reported as follows

08-31 14:57:45.007 31250-31250/com.klb.frame E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.klb.frame, PID: 31250
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.klb.frame/com.klb.frame.ui.activity.fula_home.repayment.NewEmailImportBillActivity}: java.lang.InstantiationException: java.lang.Class<com.klb.frame.ui.activity.fula_home.repayment.NewEmailImportBillActivity> cannot be instantiated
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3092)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
    at android.app.ActivityThread.-wrap12(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
    at android.os.Handler.dispatchMessage(Handler.java:108)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:7425)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
    Caused by: java.lang.InstantiationException: java.lang.Class<com.klb.frame.ui.activity.fula_home.repayment.NewEmailImportBillActivity> cannot be instantiated
    at java.lang.Class.newInstance(Native Method)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1178)
    at com.qiyukf.unicorn.i.a.newActivity(Unknown Source:2)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3082)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302) 
    at android.app.ActivityThread.-wrap12(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891) 
    at android.os.Handler.dispatchMessage(Handler.java:108) 
    at android.os.Looper.loop(Looper.java:166) 
    at android.app.ActivityThread.main(ActivityThread.java:7425) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 

activity cannot be instantiated. The solution is as follows:

1. Whether the current activity has been registered in AndroidManifest.xml - the current activity has been registered, unresolved;

2. Check to see if the package name of the current activity is consistent with the package name in AndroidManifest.xml (although I did not reintroduce the package, I checked it again) - the package name has not been modified, not resolved;

3. The above two cases are not solved, and they feel unwilling when they decide to rewrite, so they check the error-reporting activity code and find that an abstract has been added to the activity to solve the problem after modification.

The reason for this is that when you write code, you are not attentive. When you use shortcut keys to directly introduce methods, you don't pay attention to the content introduced, which leads to the definition of abstract classes. Record this problem and prevent the next time you do it again.

Off-topic remark: IDE provides us with great convenience, but it is also essential to concentrate on writing code. After all, more attention will waste less time.

 

Posted by darga333 on Sun, 03 Feb 2019 18:12:16 -0800