Android 报错please invoke x.Ext.init(app) on Application#onCreate() and register your Application

Import the xUtils framework according to the steps on GitHub

1---- Add the following dependencies when building with Gradle

implementation 'org.xutils:xutils:3.9.0'

2----Add permissions in the manifest file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

3---- initialize in the application's onCreate

x.Ext.init(this);

After the above operations are completed, run the program happily, and a string of red codes will appear in front of you, as follows:

As for why it reports an error, I don't know, the above operations are all added. After some searching on the Internet, I probably know the reason.

Solution: Step 1: Since the error is reported in the manifest, it is thought that the four major components must be registered in the manifest, so declare one. Find the activity that just inherited the application, and register it in the manifest ( I am here.UniteApplication)

The second step is to add the application in the AndroidManifest file:

Android :name=".UniteApplication" 

After the addition is complete, the code can run normally.

Guess you like

Origin blog.csdn.net/qq_62079241/article/details/131024914