当我将我的android工作室更新为3.1.2
时,我收到了此错误:
java.lang.RuntimeException:无法获取提供者com.google.firebase.provider.FirebaseInitProvider:java.lang.ClassNotFoundException:未在路径上找到“com.google.firebase.provider.FirebaseInitProvider”类:DexPathList < / p>
build.gradle
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "8g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
清单
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="com.example.ApplicationManager">
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
com.example.ApplicationManager
public class ApplicationManager extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
答案 0 :(得分:0)
试试这段代码。
public class ApplicationManager extends MultiDexApplication{
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
答案 1 :(得分:0)
您在扩展中使用了application
类:
在扩展应用程序类中使用以下类:
public class ApplicationManager extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
并将此行放在manifest中的应用程序类中:
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/app_icon_new"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme"