我认为您应该将AnalyticsApplication
班级扩展到自己的班级,如下所示:
public class YourApplicationName extends AnalyticsApplication {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
//Analitycs
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
mTracker.setScreenName("Splash");
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
// Here you will enable Multidex
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(getBaseContext());
}
}
之后,您必须将AndroidManifest.xml
文件更改为此:
<application
android:name="path.to.YourApplicationName"
...
请检查此链接以获取更多信息:http ://developer.android.com/reference/android/support/multidex/MultiDex.html