没有找到“com.google.firebase.provider.FirebaseInitProvider”类?

时间:2021-11-17 19:46:11

I am getting the below exception on app launch.

我在应用程序启动时遇到以下异常。

java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.vfirst.ifbagro-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.vfirst.ifbagro-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4993)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4596)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4536)
at android.app.ActivityThread.access$1300(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.vfirst.ifbagro-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.vfirst.ifbagro-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.installProvider(ActivityThread.java:4978)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4596) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4536) 
at android.app.ActivityThread.access$1300(ActivityThread.java:149) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5214) 
at java.lang.reflect.Method.invokeNative(Native Method) 

Here is the the app level build.gradle

这是app level build.gradle

apply plugin: 'com.android.application'
apply plugin: 'android-apt' 

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
    applicationId "com.vfirst.ifbagro"
    minSdkVersion 17
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])


compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.android.gms:play-services:9.4.0'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

This is my application level build.gradle

这是我的应用程序级build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
     delete rootProject.buildDir
}

How to solve the issue?

如何解决这个问题?

15 个解决方案

#1


85  

I had the same error and I solved it with MultiDex, like described on this link : https://developer.android.com/studio/build/multidex.html

我有同样的错误,我用MultiDex解决了它,如此链接所述:https://developer.android.com/studio/build/multidex.html

#2


59  

I too faced same issue and finally solved it by disabling Instant Run in android studio.

我也面临同样的问题,最后通过在Android studio中禁用Instant Run来解决它。

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run

设置→构建,执行,部署→即时运行并取消选中启用即时运行

#3


36  

In the build.gradle(Module:app) file, insert the code below into defaultConfig :

在build.gradle(Module:app)文件中,将下面的代码插入defaultConfig:

  defaultConfig {
        applicationId "com.***.****"
minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

and insert into to dependencies :

并插入依赖项:

compile 'com.android.support:multidex:1.0.1'

Then add code to manifest :

然后将代码添加到清单:

<application 
    android:name="android.support.multidex.MultiDexApplication"

#4


24  

I had the same problem in my (YouTube player project)... and the following solved the problem for me:

我在(YouTube播放器项目)中遇到了同样的问题......以下问题解决了我的问题:

  1. Add this code into your build.gradle (module: app) inside defaultConfing:

    将此代码添加到defaultConfing中的build.gradle(module:app)中:

    defaultConfig {
        ....
        ....
        multiDexEnabled = true
    }
    
  2. Add this code into your build.gradle (module: app) inside dependencies:

    将此代码添加到依赖项内的build.gradle(module:app)中:

    dependencies {
        compile 'com.android.support:multidex:1.0.1'
        .....
        .....
    }
    
  3. Open AndroidManifest.xml and within application:

    在应用程序中打开AndroidManifest.xml:

    <application
        android:name="android.support.multidex.MultiDexApplication"
        .....
        .....
    </application>
    

    or if you have your App class, extend it from MultiDexApplication like:

    或者如果您有App类,请从MultiDexApplication扩展它,如:

    public class MyApp extends MultiDexApplication {
    .....
    

And finally, I think you should have Android Support Repository downloaded, in the Extras in SDK Manager.

最后,我认为您应该在SDK Manager的Extras中下载Android Support Repository。

#5


17  

Just override the following method in your application class.

只需在应用程序类中覆盖以下方法即可。

public class YourApplication extends Application {

    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
    @Override
    public void onCreate() {
        super.onCreate();
        Realm.init(this); //initialize other plugins 

    }
}

#6


10  

Enabling multidex is not a good solution because multidexhave another usage in android see this answer what is multidex

启用multidex不是一个好的解决方案,因为multidex在android中有另一种用法,请看这个答案是什么是multidex

The solution is disabling instant run as @Shylendra Madda said

正如@Shylendra Madda所说,解决方案正在禁用即时运行

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run

设置→构建,执行,部署→即时运行并取消选中启用即时运行

I think the reason of this problem is when instant run is enabled, Android Studio don't put libraries such as firebase into generated apk to decreasing project build time because firebase library and other libraries such as maps and others is exist in play services and play services is installed on android device so if instant run enabled don't need to put them in generated apk to make build time faster.

我认为这个问题的原因是当启用即时运行时,Android Studio不会将诸如firebase之类的库放入生成的apk中以减少项目构建时间,因为firebase库和其他库(如地图等)存在于播放服务和播放中在Android设备上安装了服务,因此如果启用了即时运行,则不需要将它们放入生成的apk中以使构建时间更快。

So when you extract apk and install it on another device you will see this exception

因此,当您解压缩apk并将其安装在另一台设备上时,您将看到此异常

#7


5  

If you are using MultiDex in your App Gradle then change extends application to extends MultiDexApplication in your application class. It will defiantly work

如果您在App Gradle中使用MultiDex,则更改扩展应用程序以在您的应用程序类中扩展MultiDexApplication。它会顽强地工作

#8


4  

First add the following into build.gradle(Module:app)---->

首先将以下内容添加到build.gradle(Module:app)---->中

defaultConfig{
..
multiDexEnabled true
..
}

Then in same file add the following

然后在同一文件中添加以下内容

dependencies{
...
compile 'com.android.support:multidex:1.0.1'
...
}

Then in AndroidManifest.xml write the following

然后在AndroidManifest.xml中编写以下内容

<application
    android:name="android.support.multidex.MultiDexApplication"
    .....
    .....
</application>

That's it. It will definitely work

而已。它肯定会奏效

#9


4  

When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture

当您的应用及其引用的库超过65,536种方法时,您会遇到构建错误,表明您的应用已达到Android构建架构的限制

To avoid this limitation you have to configure your app for multidex

要避免此限制,您必须为multidex配置应用程序

If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:

如果你的minSdkVersion设置为21或更高,你需要做的就是在你的模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...   
}

However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

但是,如果您的minSdkVersion设置为20或更低,则必须使用multidex支持库,如下所示:

1.Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

1.修改模块级build.gradle文件以启用multidex并将multidex库添加为依赖项,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
 }

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

2.Depending on whether you override the Application class, perform one of the following:

2.根据您是否重写Application类,执行以下操作之一:

  • If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:
  • 如果不覆盖Application类,请编辑清单文件以在标记中设置android:name,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
    <application
        android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>
  • If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:
  • 如果您覆盖Application类,请将其更改为扩展MultiDexApplication(如果可能),如下所示:

public class MyApplication extends MultiDexApplication { ... }

公共类MyApplication扩展了MultiDexApplication {...}

  • Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:
  • 或者,如果您重写Application类但无法更改基类,则可以改为覆盖attachBaseContext()方法并调用MultiDex.install(this)以启用multidex:

public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

#10


3  

I have also face the same issue after trying all solution I found the below solution.

在尝试所有解决方案后,我也遇到了同样的问题,我找到了以下解决方案。

If you have applied proguard rules then add below line in ProGuard Rules

如果您已应用了proguard规则,请在ProGuard规则中添加以下行

-keep class com.google.firebase.provider.FirebaseInitProvider

and its solve my problem.

它解决了我的问题。

#11


1  

I had the same issue and solved just add a piece of code, If you are getting this issue means you had already completed all the steps that need to use Firebase. You just need to create a class that extends the Application (public class Application_CrashReport extends Application ) and add this class in mainifest file and In that class just override the below method

我有同样的问题并解决了只需添加一段代码,如果您遇到此问题意味着您已经完成了需要使用Firebase的所有步骤。您只需要创建一个扩展Application的类(公共类Application_CrashReport extends Application)并在mainifest文件中添加该类,并在该类中覆盖以下方法

  @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
}

and add MultiDex.install(this); in that method means

并添加MultiDex.install(this);在那个方法意味着

  @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

Note :- Don't forget to follow above steps

注意: - 不要忘记按照上述步骤操作

#12


1  

This is due to MultiDex.

这是由于MultiDex。

Steps to solve:

要解决的步骤:

  1. In gradle->dependencies->(compile'com.android.support:multidex:1.0.1') Add this in dependencies

    在gradle-> dependencies - >(compile'c​​om.android.support:multidex:1.0.1')在依赖项中添加它

  2. In your project application class extends MultiDexApplication like this (public class MyApplication extends MultiDexApplication)

    在您的项目中,应用程序类扩展了MultiDexApplication(公共类MyApplication扩展MultiDexApplication)

  3. Run and check

    运行并检查

#13


0  

1: Go to the gradle enable multiDexEnabled and add the multidex library in the dependencies.

1:转到gradle enable multiDexEnabled并在依赖项中添加multidex库。

android {
   ...
   defaultConfig {
      multiDexEnabled true
      ...
   }
}

dependencies {
  // add dependency 
  compile 'com.android.support:multidex:1.0.1'
}

2: Go to the Manifest file and write android:name=".MyApplication" (Class name(MyApplication) is optional you can write whatever you want ).

2:转到Manifest文件并写入android:name =“。MyApplication”(类名(MyApplication)是可选的,你可以写任何你想要的)。

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

3: As you wrote android:name=".MyApplication" Inside Application at Manifest file. it will give you an error because you didn't create MyApplication class. Create MyApplication Class extend it by "application" class or Simply click on.MyApplication, a small red balloon appear on the left side of a syntax click on it, you will see (create MyApplication class) in the menu, click on it and Include below Method Inside that class.

3:正如您在Manifest文件中编写的android:name =“。MyApplication”Inside Application。它会给你一个错误,因为你没有创建MyApplication类。创建MyApplication类通过“application”类扩展它或者只需单击.MyApplication,在语法左侧出现一个小红色气球点击它,您将在菜单中看到(创建MyApplication类),单击它并包含下面的方法在该类中。

    public class MyApplication extends Application {

    @Override 
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    } 

If you want to get more information then Click on this Link:[https://developer.android.com/studio/build/multidex.html]

如果您想获得更多信息,请点击此链接:[https://developer.android.com/studio/build/multidex.html]

Hopefully, It works for you.

希望它适合你。

#14


0  

You should extend your Application class with MultiDexApplication instead of Application.

您应该使用MultiDexApplication而不是Application扩展Application类。

#15


-4  

add in project root path google-services.json

添加项目根路径google-services.json

dependencies {
compile 'com.android.support:support-v4:25.0.1'
**compile 'com.google.firebase:firebase-ads:9.0.2'**
compile files('libs/StartAppInApp-3.5.0.jar')
compile 'com.android.support:multidex:1.0.1'
  }
apply plugin: 'com.google.gms.google-services'

#1


85  

I had the same error and I solved it with MultiDex, like described on this link : https://developer.android.com/studio/build/multidex.html

我有同样的错误,我用MultiDex解决了它,如此链接所述:https://developer.android.com/studio/build/multidex.html

#2


59  

I too faced same issue and finally solved it by disabling Instant Run in android studio.

我也面临同样的问题,最后通过在Android studio中禁用Instant Run来解决它。

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run

设置→构建,执行,部署→即时运行并取消选中启用即时运行

#3


36  

In the build.gradle(Module:app) file, insert the code below into defaultConfig :

在build.gradle(Module:app)文件中,将下面的代码插入defaultConfig:

  defaultConfig {
        applicationId "com.***.****"
minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

and insert into to dependencies :

并插入依赖项:

compile 'com.android.support:multidex:1.0.1'

Then add code to manifest :

然后将代码添加到清单:

<application 
    android:name="android.support.multidex.MultiDexApplication"

#4


24  

I had the same problem in my (YouTube player project)... and the following solved the problem for me:

我在(YouTube播放器项目)中遇到了同样的问题......以下问题解决了我的问题:

  1. Add this code into your build.gradle (module: app) inside defaultConfing:

    将此代码添加到defaultConfing中的build.gradle(module:app)中:

    defaultConfig {
        ....
        ....
        multiDexEnabled = true
    }
    
  2. Add this code into your build.gradle (module: app) inside dependencies:

    将此代码添加到依赖项内的build.gradle(module:app)中:

    dependencies {
        compile 'com.android.support:multidex:1.0.1'
        .....
        .....
    }
    
  3. Open AndroidManifest.xml and within application:

    在应用程序中打开AndroidManifest.xml:

    <application
        android:name="android.support.multidex.MultiDexApplication"
        .....
        .....
    </application>
    

    or if you have your App class, extend it from MultiDexApplication like:

    或者如果您有App类,请从MultiDexApplication扩展它,如:

    public class MyApp extends MultiDexApplication {
    .....
    

And finally, I think you should have Android Support Repository downloaded, in the Extras in SDK Manager.

最后,我认为您应该在SDK Manager的Extras中下载Android Support Repository。

#5


17  

Just override the following method in your application class.

只需在应用程序类中覆盖以下方法即可。

public class YourApplication extends Application {

    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
    @Override
    public void onCreate() {
        super.onCreate();
        Realm.init(this); //initialize other plugins 

    }
}

#6


10  

Enabling multidex is not a good solution because multidexhave another usage in android see this answer what is multidex

启用multidex不是一个好的解决方案,因为multidex在android中有另一种用法,请看这个答案是什么是multidex

The solution is disabling instant run as @Shylendra Madda said

正如@Shylendra Madda所说,解决方案正在禁用即时运行

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run

设置→构建,执行,部署→即时运行并取消选中启用即时运行

I think the reason of this problem is when instant run is enabled, Android Studio don't put libraries such as firebase into generated apk to decreasing project build time because firebase library and other libraries such as maps and others is exist in play services and play services is installed on android device so if instant run enabled don't need to put them in generated apk to make build time faster.

我认为这个问题的原因是当启用即时运行时,Android Studio不会将诸如firebase之类的库放入生成的apk中以减少项目构建时间,因为firebase库和其他库(如地图等)存在于播放服务和播放中在Android设备上安装了服务,因此如果启用了即时运行,则不需要将它们放入生成的apk中以使构建时间更快。

So when you extract apk and install it on another device you will see this exception

因此,当您解压缩apk并将其安装在另一台设备上时,您将看到此异常

#7


5  

If you are using MultiDex in your App Gradle then change extends application to extends MultiDexApplication in your application class. It will defiantly work

如果您在App Gradle中使用MultiDex,则更改扩展应用程序以在您的应用程序类中扩展MultiDexApplication。它会顽强地工作

#8


4  

First add the following into build.gradle(Module:app)---->

首先将以下内容添加到build.gradle(Module:app)---->中

defaultConfig{
..
multiDexEnabled true
..
}

Then in same file add the following

然后在同一文件中添加以下内容

dependencies{
...
compile 'com.android.support:multidex:1.0.1'
...
}

Then in AndroidManifest.xml write the following

然后在AndroidManifest.xml中编写以下内容

<application
    android:name="android.support.multidex.MultiDexApplication"
    .....
    .....
</application>

That's it. It will definitely work

而已。它肯定会奏效

#9


4  

When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture

当您的应用及其引用的库超过65,536种方法时,您会遇到构建错误,表明您的应用已达到Android构建架构的限制

To avoid this limitation you have to configure your app for multidex

要避免此限制,您必须为multidex配置应用程序

If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:

如果你的minSdkVersion设置为21或更高,你需要做的就是在你的模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...   
}

However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

但是,如果您的minSdkVersion设置为20或更低,则必须使用multidex支持库,如下所示:

1.Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

1.修改模块级build.gradle文件以启用multidex并将multidex库添加为依赖项,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
 }

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

2.Depending on whether you override the Application class, perform one of the following:

2.根据您是否重写Application类,执行以下操作之一:

  • If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:
  • 如果不覆盖Application类,请编辑清单文件以在标记中设置android:name,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
    <application
        android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>
  • If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:
  • 如果您覆盖Application类,请将其更改为扩展MultiDexApplication(如果可能),如下所示:

public class MyApplication extends MultiDexApplication { ... }

公共类MyApplication扩展了MultiDexApplication {...}

  • Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:
  • 或者,如果您重写Application类但无法更改基类,则可以改为覆盖attachBaseContext()方法并调用MultiDex.install(this)以启用multidex:

public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

#10


3  

I have also face the same issue after trying all solution I found the below solution.

在尝试所有解决方案后,我也遇到了同样的问题,我找到了以下解决方案。

If you have applied proguard rules then add below line in ProGuard Rules

如果您已应用了proguard规则,请在ProGuard规则中添加以下行

-keep class com.google.firebase.provider.FirebaseInitProvider

and its solve my problem.

它解决了我的问题。

#11


1  

I had the same issue and solved just add a piece of code, If you are getting this issue means you had already completed all the steps that need to use Firebase. You just need to create a class that extends the Application (public class Application_CrashReport extends Application ) and add this class in mainifest file and In that class just override the below method

我有同样的问题并解决了只需添加一段代码,如果您遇到此问题意味着您已经完成了需要使用Firebase的所有步骤。您只需要创建一个扩展Application的类(公共类Application_CrashReport extends Application)并在mainifest文件中添加该类,并在该类中覆盖以下方法

  @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
}

and add MultiDex.install(this); in that method means

并添加MultiDex.install(this);在那个方法意味着

  @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

Note :- Don't forget to follow above steps

注意: - 不要忘记按照上述步骤操作

#12


1  

This is due to MultiDex.

这是由于MultiDex。

Steps to solve:

要解决的步骤:

  1. In gradle->dependencies->(compile'com.android.support:multidex:1.0.1') Add this in dependencies

    在gradle-> dependencies - >(compile'c​​om.android.support:multidex:1.0.1')在依赖项中添加它

  2. In your project application class extends MultiDexApplication like this (public class MyApplication extends MultiDexApplication)

    在您的项目中,应用程序类扩展了MultiDexApplication(公共类MyApplication扩展MultiDexApplication)

  3. Run and check

    运行并检查

#13


0  

1: Go to the gradle enable multiDexEnabled and add the multidex library in the dependencies.

1:转到gradle enable multiDexEnabled并在依赖项中添加multidex库。

android {
   ...
   defaultConfig {
      multiDexEnabled true
      ...
   }
}

dependencies {
  // add dependency 
  compile 'com.android.support:multidex:1.0.1'
}

2: Go to the Manifest file and write android:name=".MyApplication" (Class name(MyApplication) is optional you can write whatever you want ).

2:转到Manifest文件并写入android:name =“。MyApplication”(类名(MyApplication)是可选的,你可以写任何你想要的)。

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

3: As you wrote android:name=".MyApplication" Inside Application at Manifest file. it will give you an error because you didn't create MyApplication class. Create MyApplication Class extend it by "application" class or Simply click on.MyApplication, a small red balloon appear on the left side of a syntax click on it, you will see (create MyApplication class) in the menu, click on it and Include below Method Inside that class.

3:正如您在Manifest文件中编写的android:name =“。MyApplication”Inside Application。它会给你一个错误,因为你没有创建MyApplication类。创建MyApplication类通过“application”类扩展它或者只需单击.MyApplication,在语法左侧出现一个小红色气球点击它,您将在菜单中看到(创建MyApplication类),单击它并包含下面的方法在该类中。

    public class MyApplication extends Application {

    @Override 
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    } 

If you want to get more information then Click on this Link:[https://developer.android.com/studio/build/multidex.html]

如果您想获得更多信息,请点击此链接:[https://developer.android.com/studio/build/multidex.html]

Hopefully, It works for you.

希望它适合你。

#14


0  

You should extend your Application class with MultiDexApplication instead of Application.

您应该使用MultiDexApplication而不是Application扩展Application类。

#15


-4  

add in project root path google-services.json

添加项目根路径google-services.json

dependencies {
compile 'com.android.support:support-v4:25.0.1'
**compile 'com.google.firebase:firebase-ads:9.0.2'**
compile files('libs/StartAppInApp-3.5.0.jar')
compile 'com.android.support:multidex:1.0.1'
  }
apply plugin: 'com.google.gms.google-services'