请在使用 Firebase UI 时为 VectorDrawableCompat 配置构建
Please configure your build for VectorDrawableCompat while using Firebase UI
我遇到了这个错误:
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
但是这个错误是在添加 Firebase UI 依赖项之后出现的:
compile 'com.firebaseui:firebase-ui:0.4.3'
我看过 this and this post,但似乎对我没有任何用处,即使我的项目中没有 Vector Drawables,但我想知道为什么它给我这个错误信息。下面是我的 logcat:
10-03 04:58:29.699 1256-1270/system_process E/WindowManager: Starting window AppWindowToken{b13967c8 token=Token{b1990890 ActivityRecord{b1778df8 u0 pixsor.app.huzykamz.pixoradmin/.MainActivity t8}}} timed out
10-03 05:03:21.954 1256-1326/system_process A/ActivityManager: Service ServiceRecord{b199ac38 u0 pixsor.app.huzykamz.pixoradmin/com.google.android.gms.measurement.AppMeasurementService} in process ProcessRecord{b12b8bd0 21551:pixsor.app.huzykamz.pixoradmin/u0a62} not same as in map: null
10-03 05:06:42.187 25698-25698/? E/memtrack: Couldn't load memtrack module (No such file or directory)
10-03 05:06:42.187 25698-25698/? E/android.os.Debug: failed to load memtrack module: -2
10-03 05:06:50.057 25715-25715/? E/memtrack: Couldn't load memtrack module (No such file or directory)
10-03 05:06:50.057 25715-25715/? E/android.os.Debug: failed to load memtrack module: -2
10-03 05:06:51.257 25725-25725/pixsor.app.huzykamz.pixoradmin E/FirebaseCrash: Failed to initialize crash reporting
com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access00(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsb.zza(Unknown Source)
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access00(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
10-03 05:06:52.017 25725-25725/pixsor.app.huzykamz.pixoradmin E/AndroidRuntime: FATAL EXCEPTION: main
Process: pixsor.app.huzykamz.pixoradmin, PID: 25725
java.lang.RuntimeException: Unable to start activity ComponentInfo{pixsor.app.huzykamz.pixoradmin/pixsor.app.huzykamz.pixoradmin.MainActivity}: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at pixsor.app.huzykamz.pixoradmin.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
10-03 05:07:00.247 1256-1270/system_process E/WindowManager: Starting window AppWindowToken{b1464090 token=Token{b1324070 ActivityRecord{b12a1f80 u0 pixsor.app.huzykamz.pixoradmin/.MainActivity t9}}} timed out
10-03 05:11:52.681 1256-1439/system_process A/ActivityManager: Service ServiceRecord{b199c5d0 u0 pixsor.app.huzykamz.pixoradmin/com.google.android.gms.measurement.AppMeasurementService} in process ProcessRecord{b11b7fc0 25725:pixsor.app.huzykamz.pixoradmin/u0a62} not same as in map: null
这是我的 gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
// vectorDrawables.useSupportLibrary = true
applicationId "pixsor.app.huzykamz.pixoradmin"
minSdkVersion 16
targetSdkVersion 23
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
错误显示在 onCreate
方法的这一行:
super.onCreate(savedInstanceState);
这是我的onCreate
方法:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
mDatabase.keepSynced(true);
mRecyclerview =(RecyclerView)findViewById(R.id.mRecyclerview);
mRecyclerview.hasFixedSize();
mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, PostActivity.class));
}
});
}
为什么会发生这种情况,我该如何解决?
尝试将此添加到您的 gradle 中,但请检查您的 gradle 版本。
for Gradle2.0+插件
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
...
}
}
for Gradle 2.0 之前的插件
android {
defaultConfig {
generatedDensities = []
...
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
我的所有 Gradle 文件设置为:
vectorDrawables.useSupportLibrary = true
但是问题发生在我从sdk 27升级到28之后
然后我开始遇到这个问题。
我做了 google,但最终,我注意到了构建文件,我从项目目录中删除了所有构建文件(干净的项目不起作用,我不知道为什么)
我重建了,效果非常好!
我不得不添加对 module: app
级别 gradle 文件的支持库依赖,
dependencies {
....
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
....
}
并添加
android {
defaultConfig {
......
vectorDrawables.useSupportLibrary = true
}
}
然后同步项目并构建它。
我遇到了这个错误:
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
但是这个错误是在添加 Firebase UI 依赖项之后出现的:
compile 'com.firebaseui:firebase-ui:0.4.3'
我看过 this and this post,但似乎对我没有任何用处,即使我的项目中没有 Vector Drawables,但我想知道为什么它给我这个错误信息。下面是我的 logcat:
10-03 04:58:29.699 1256-1270/system_process E/WindowManager: Starting window AppWindowToken{b13967c8 token=Token{b1990890 ActivityRecord{b1778df8 u0 pixsor.app.huzykamz.pixoradmin/.MainActivity t8}}} timed out
10-03 05:03:21.954 1256-1326/system_process A/ActivityManager: Service ServiceRecord{b199ac38 u0 pixsor.app.huzykamz.pixoradmin/com.google.android.gms.measurement.AppMeasurementService} in process ProcessRecord{b12b8bd0 21551:pixsor.app.huzykamz.pixoradmin/u0a62} not same as in map: null
10-03 05:06:42.187 25698-25698/? E/memtrack: Couldn't load memtrack module (No such file or directory)
10-03 05:06:42.187 25698-25698/? E/android.os.Debug: failed to load memtrack module: -2
10-03 05:06:50.057 25715-25715/? E/memtrack: Couldn't load memtrack module (No such file or directory)
10-03 05:06:50.057 25715-25715/? E/android.os.Debug: failed to load memtrack module: -2
10-03 05:06:51.257 25725-25725/pixsor.app.huzykamz.pixoradmin E/FirebaseCrash: Failed to initialize crash reporting
com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access00(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsb.zza(Unknown Source)
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access00(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
10-03 05:06:52.017 25725-25725/pixsor.app.huzykamz.pixoradmin E/AndroidRuntime: FATAL EXCEPTION: main
Process: pixsor.app.huzykamz.pixoradmin, PID: 25725
java.lang.RuntimeException: Unable to start activity ComponentInfo{pixsor.app.huzykamz.pixoradmin/pixsor.app.huzykamz.pixoradmin.MainActivity}: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at pixsor.app.huzykamz.pixoradmin.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
10-03 05:07:00.247 1256-1270/system_process E/WindowManager: Starting window AppWindowToken{b1464090 token=Token{b1324070 ActivityRecord{b12a1f80 u0 pixsor.app.huzykamz.pixoradmin/.MainActivity t9}}} timed out
10-03 05:11:52.681 1256-1439/system_process A/ActivityManager: Service ServiceRecord{b199c5d0 u0 pixsor.app.huzykamz.pixoradmin/com.google.android.gms.measurement.AppMeasurementService} in process ProcessRecord{b11b7fc0 25725:pixsor.app.huzykamz.pixoradmin/u0a62} not same as in map: null
这是我的 gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
// vectorDrawables.useSupportLibrary = true
applicationId "pixsor.app.huzykamz.pixoradmin"
minSdkVersion 16
targetSdkVersion 23
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
错误显示在 onCreate
方法的这一行:
super.onCreate(savedInstanceState);
这是我的onCreate
方法:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
mDatabase.keepSynced(true);
mRecyclerview =(RecyclerView)findViewById(R.id.mRecyclerview);
mRecyclerview.hasFixedSize();
mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, PostActivity.class));
}
});
}
为什么会发生这种情况,我该如何解决?
尝试将此添加到您的 gradle 中,但请检查您的 gradle 版本。
for Gradle2.0+插件
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
...
}
}
for Gradle 2.0 之前的插件
android {
defaultConfig {
generatedDensities = []
...
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
我的所有 Gradle 文件设置为:
vectorDrawables.useSupportLibrary = true
但是问题发生在我从sdk 27升级到28之后
然后我开始遇到这个问题。
我做了 google,但最终,我注意到了构建文件,我从项目目录中删除了所有构建文件(干净的项目不起作用,我不知道为什么)
我重建了,效果非常好!
我不得不添加对 module: app
级别 gradle 文件的支持库依赖,
dependencies {
....
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
....
}
并添加
android {
defaultConfig {
......
vectorDrawables.useSupportLibrary = true
}
}
然后同步项目并构建它。