Multidex和Singleton类在清单应用程序标记中使用android:name
我有一个应用程序,我使用了Multidex和Singleton类在清单应用程序标记中使用android:name,android,singleton,android-manifest,dalvik,android-multidex,Android,Singleton,Android Manifest,Dalvik,Android Multidex,我有一个应用程序,我使用了Singleton。我只是犯了个错误。我通过编译依赖项和gradle-multiDexEnabled true <application android:allowBackup="true" android:allowClearUserData="true" android:fullBackupContent="true" android:hardwareAccelerated="true" android:icon="@m
Singleton
。我只是犯了个错误。我通过编译依赖项和gradle-multiDexEnabled true
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:fullBackupContent="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="app.project.SingletonController"
>
<!--android:name="android.support.multidex.MultiDexApplication"-->
在同一链接中,中的应包含在清单中->您已经为应用程序定义了自定义应用程序类SingletonController
MultiDexApplication
是一个简单的实用程序类,您可以将其用作自己的SingletonController
的超级类。如果由于某种原因这是不可能的,您必须自己实现该功能
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
自2014年12月3日起,发布了构建工具1.0.0-rc1。现在,您需要做的就是修改build.gradle
}
依赖关系{
编译'com.android.support:multidex:1.0.1'
}
如果您正在运行单元测试,您将希望在应用程序类中包括:
}所以我将在我的单声道控制器中覆盖这个?只有不适用于其他活动
?单例控制器
应直接或间接扩展应用程序
。如果它是直接的,只需扩展MultiDexApplication
。否则调用此MultiDex.install(this)
。这就是你的问题所在。我已经在我的SingletonController中覆盖了那个。非常感谢。除了像MainActivity
这样的SingletonController
类之外,这也是可重写的吗?不,仅在应用程序中。这是旧版本上类加载器的设置。然后每个活动都会自动使用它。谢谢您的回答。我已经按照他们的医生说的那样完成了这些步骤。让我感到困惑的是清单
部分:
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}