请在使用Firebase UI时为VectorDrawableCompat配置构建

时间:2016-10-03 09:50:59

标签: android firebase firebaseui android-vectordrawable

我正面临这个错误:

Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.

但是在添加 Firebase用户界面依赖关系后出现了这个错误:

compile 'com.firebaseui:firebase-ui:0.4.3'

我看过thispost,但似乎没有什么对我有用,即使我的项目中没有 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.access$1500(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.access$1500(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.access$800(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.access$800(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

这是我的傻瓜:

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

为什么会发生这种情况,我该如何解决?

3 个答案:

答案 0 :(得分:4)

尝试在您的gradle中添加此内容,但请检查您的gradle版本。

适用于Gradle2.0 +插件

android {
  defaultConfig {
    vectorDrawables.useSupportLibrary = true
    ...
  }
}

适用于2.0之前的Gradle插件

android {
  defaultConfig {
    generatedDensities = []
    ...  
  }

  aaptOptions {
   additionalParameters "--no-version-vectors"
  }
}

答案 1 :(得分:0)

我用以下方法设置了所有Gradle文件:

vectorDrawables.useSupportLibrary = true

但是问题是在我从sdk 27​​升级到28之后发生的。

然后我开始遇到这个问题。

我在Google上搜索过它,但最终,我将注意力转移到了生成文件上,我从项目目录中删除了所有生成文件(干净的项目无法正常工作,我不知道为什么)

我重建了,它就像一个魅力!

答案 2 :(得分:0)

我必须在module: app级gradle文件中添加支持库依赖项,

dependencies {
    ....
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    ....
}

并添加

android {
    defaultConfig {
        ......
        vectorDrawables.useSupportLibrary = true
    }
}

然后同步项目并构建它。