Приложение становится разбитым, и я не могу это понять

Во-первых, я получил исключение индекса и после того, как недействительный кэш мое приложение разбилось, пожалуйста, помогите? Я добавил файл logcat и build.gradle. Это дает ошибку в основной деятельности, хотя код там есть.

Logcat:

15793-15793/com.example.user.e_mart E/VdcInflateDelegate﹕ Exception while inflating <vector>
        org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
                at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
                at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
                at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
                at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
                at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
                at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:226)
                at android.support.v7.app.AppCompatViewInflater.createViewFromTag(AppCompatViewInflater.java:175)
                at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:146)
                at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:963)
                at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1022)
                at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                at com.example.user.e_mart.MainActivity.onCreate(MainActivity.java:20)
                at android.app.Activity.performCreate(Activity.java:5182)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                at dalvik.system.NativeStart.main(Native Method)
    02-27 15:39:33.032  15793-15793/com.example.user.e_mart E/test﹕ Exception
    02-27 15:39:33.036  15793-15793/com.example.user.e_mart E/AndroidRuntime﹕ FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.e_mart/com.example.user.e_mart.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.Toolbar
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.Toolbar
                at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                at com.example.user.e_mart.MainActivity.onCreate(MainActivity.java:20)
                at android.app.Activity.performCreate(Activity.java:5182)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: java.lang.reflect.InvocationTargetException
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                at com.example.user.e_mart.MainActivity.onCreate(MainActivity.java:20)
                at android.app.Activity.performCreate(Activity.java:5182)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
                at android.content.res.Resources.loadDrawable(Resources.java:1998)
                at android.content.res.Resources.getDrawable(Resources.java:678)
                at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
                at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
                at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
                at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
                at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                at com.example.user.e_mart.MainActivity.onCreate(MainActivity.java:20)
                at android.app.Activity.performCreate(Activity.java:5182)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
                at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:920)
                at android.graphics.drawable.Drawable.createFromXml(Drawable.java:852)
                at android.content.res.Resources.loadDrawable(Resources.java:1995)
                at android.content.res.Resources.getDrawable(Resources.java:678)
                at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
                at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
                at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
                at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
                at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
                at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
                at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
                at com.example.user.e_mart.MainActivity.onCreate(MainActivity.java:20)
                at android.app.Activity.performCreate(Activity.java:5182)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
                at android.app.ActivityThread.access$600(ActivityThread.java:156)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:153)
                at android.app.ActivityThread.main(ActivityThread.java:5299)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)

Gradle файл:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.user.e_mart"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    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:23.2.0'
    compile 'com.android.support:design:23.2.0'

}

Ответ 1

Я исправил эту проблему, заменив

dependencies {

compile 'com.android.support:appcompat-v7:23.2.0'

compile 'com.android.support:design:23.2.0'
}

с

dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'

compile 'com.android.support:design:23.0.1'
}

Ответ 2

Я получил эту же ошибку в Android Studio 2.2 после того, как обновил мои зависимости Gradle до последних версий, но забыл обновить buildToolsVersion моего проекта.

Я изменил:

compile 'com.android.support:appcompat-v7:22.2.1'

в

compile 'com.android.support:appcompat-v7:24.2.1'

В то время как buildToolsVersion остался в "22.0.1" следующим образом:

buildToolsVersion "22.0.1"

Итак, все, что я делал, - это обновить buildToolsVersion до 24 так:

buildToolsVersion "24"

так как ранее он был загружен с помощью SDK Manager. Поэтому проверьте последнюю версию Android SDK Build Tools в SDK Manager и посмотрите, соответствует ли она версии зависимостей.

Надеюсь, это поможет кому-то.

Ответ 3

Согласно Ajinkya (как найдено fooobar.com/questions/70124/...), вы можете сделать следующее:

Используйте этот код в файле build.gradle

   //for Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

Если вы используете Gradle 1.5, вместо этого используйте

defaultConfig {
        generatedDensities = []
    }

    // This is handled for you by the 2.0+ Gradle Plugin
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }

Я думаю, может быть, они используют векторный draw-able compact под other lib.found здесь

Подробнее см. здесь: Обновить библиотеку поддержки Android до ошибки 23.2.0: XmlPullParserException Бинарная строка XML файла # 17 <vector> тегу требуется viewportWidth > 0

Для ошибки (8.0)

Переименовано несколько свойств, чтобы сделать вещи более последовательными:

  • BuildType.runProguard → minifyEnabled
  • BuildType.zipAlign → zipAlignEnabled
  • BuildType.jniDebugBuild → jniDebuggable
  • BuildType.renderscriptDebug → renderscriptDebuggable
  • ProductFlavor.rderscriptSupportMode → renderscriptSupportModeEnabled
  • ProductFlavor.rderscriptNdkMode → renderscriptNdkModeEnabled

поэтому renderscriptSupportMode переименовывается в renderscriptNdkModeEnabled

Ответ 4

Попробуйте сменить styles.xml на

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

Это связано с тем, что если стиль требует ActionBar, есть вероятность не найти кнопку abc_back, но без проблемы с панелью действий.