Custom global Application class breaks with “android.app.Application cannot be cast to”

前端 未结 2 664
悲哀的现实
悲哀的现实 2020-12-02 05:25

I have a custom global class which looks like this

import android.app.Application;

public class MyApp extends Application {

    public String MainAct;

            


        
2条回答
  •  独厮守ぢ
    2020-12-02 06:03

    The error states that the type of the object returned by getApplication is android.app.Application. A possible cause for this is that you failed to define the application in the manifest. Make sure that your manifest includes something in the lines of:

    
    

提交回复
热议问题