简体   繁体   中英

Application class does not run when app start?

I am using Application class but it's not running when App start
here is my code:

public class App extends Application {
//
private static final String TAG = App.class.getSimpleName();
public static SharedPreferences sPrefs;
private static App sInstance;

public static App getsInstance() {
    return sInstance;
}

@Override
public void onCreate() {
    super.onCreate();
    if (!BuildConfig.DEBUG) {
        Fabric.with(this, new Crashlytics());
    }
    Log.e(TAG,"onCreate()");
    sInstance = this;
    sPrefs = PreferenceManager.getDefaultSharedPreferences(this);
}
//some methods
}

in AndroidManifest.xml

<application
    android:name=".App"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

when I put a breakpoint inside onCreate() and run a debug it doesn't stop on it any help?

尝试卸载 app ,清理项目并重新安装。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM