Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multidex和Singleton类在清单应用程序标记中使用android:name_Android_Singleton_Android Manifest_Dalvik_Android Multidex - Fatal编程技术网

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);
}