15

Ich versuche, Android Studio 2.2 Vorschau 1 zu verwenden, aber wenn ich ein neues Projekt erstellen und einen einfachen EditText hinzufügen und versuchen zu laufen, habe ich den folgenden Fehler.Android Studio 2.2 Vorschau 1 EditText Fehler

05-20 15:53:00.748 11798-11798/br.com.tutorialandroid.sqlite E/AndroidRuntime: FATAL EXCEPTION: main 
Process: br.com.tutorialandroid.sqlite, PID: 11798 
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.tutorialandroid.sqlite/br.com.tutorialandroid.sqlite.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class EditText 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 
at android.app.ActivityThread.access$900(ActivityThread.java:172) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5832) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class EditText 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at br.com.tutorialandroid.sqlite.MainActivity.onCreate(MainActivity.java:22) 
at android.app.Activity.performCreate(Activity.java:6221) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)  
at android.app.ActivityThread.access$900(ActivityThread.java:172)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)  
at android.os.Handler.dispatchMessage(Handler.java:102)  
at android.os.Looper.loop(Looper.java:145)  
at android.app.ActivityThread.main(ActivityThread.java:5832)  
at java.lang.reflect.Method.invoke(Native Method)  
at java.lang.reflect.Method.invoke(Method.java:372)  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)  
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_edit_text_material.xml from drawable resource ID #0x7f020015 
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3707) 
at android.content.res.Resources.loadDrawable(Resources.java:3575) 
at android.content.res.TypedArray.getDrawable(TypedArray.java:750) 
at android.view.View.<init>(View.java:3939) 
at android.widget.TextView.<init>(TextView.java:923) 
at android.widget.EditText.<init>(EditText.java:74) 
at android.widget.EditText.<init>(EditText.java:70) 
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60) 
at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56) 
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112) 
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980) 
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039) 
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)  
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933)  
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)  
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933)  
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)  
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)  
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)  
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)  
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
at br.com.tutorialandroid.sqlite.MainActivity.onCreate(MainActivity.java:22)  
at android.app.Activity.performCreate(Activity.java:6221)  
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)  
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)  
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)  
at android.app.ActivityThread.access$900(ActivityThread.java:172)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)  
at android.os.Handler.dispatchMessage(Handler.java:102)  
at android.os.Looper.loop(Looper.java:145)  
at android.app.ActivityThread.main(ActivityThread.java:5832)  
at java.lang.reflect.Method.invoke(Native Method)  
at java.lang.reflect.Method.invoke(Method.java:372)  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)  
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #24: <nine-patch> requires a valid 9-patch source image 
at android.graphics.drawable.NinePatchDrawable.updateStateFromTypedArray(NinePatchDrawable.java:445) 
at android.graphics.drawable.NinePatchDrawable.inflate(NinePatchDrawable.java:401) 
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1150) 
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:185) 
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1150) 
at android.graphics.drawable.InsetDrawable.inflate(InsetDrawable.j 

und mein Layout ist

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="br.com.tutorialandroid.sqlite.MainActivity" 
    tools:showIn="@layout/app_bar_main" 
    tools:layout_editor_absoluteX="0dp" 
    tools:layout_editor_absoluteY="81dp"> 

    <EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:inputType="textPersonName" 
    android:text="Nome" 
    android:ems="10" 
    tools:layout_editor_absoluteX="84dp" 
    tools:layout_editor_absoluteY="262dp" 
    android:id="@+id/txtNome" 
    app:layout_constraintLeft_toLeftOf="@+id/content_main" 
    tools:layout_constraintLeft_creator="0" 
    app:layout_constraintTop_toTopOf="@+id/content_main" 
    tools:layout_constraintTop_creator="0" 
    app:layout_constraintRight_toRightOf="@+id/content_main" 
    tools:layout_constraintRight_creator="0" 
    app:layout_constraintBottom_toBottomOf="@+id/content_main" 
    tools:layout_constraintBottom_creator="0" /> 

</android.support.constraint.ConstraintLayout> 

Meine build.gradle (Modulebene) Datei

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 
    defaultConfig { 
     applicationId "br.com.tutorialandroid.sqlite" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    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.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' 
    testCompile 'junit:junit:4.12' 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
    androidTestCompile 'com.android.support.test:runner:0.5' 
    androidTestCompile 'com.android.support:support-annotations:23.4.0' 
} 

und My build.gradle (App-Ebene) Datei

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

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.0-alpha1' 

     // 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 
} 

Und das ist meine Layout-Vorschau in AS 2.2 Vorschau 1

enter image description here

+0

Sie Vektor haben in Ihrem Projekt verwenden? Wenn nein, denke ich, muss sauberes Build dein Problem beheben, wenn ja, hast du 'vectorDrawables.useSupportLibrary = true' in die Datei gradle eingefügt? –

+0

@shayanpourvatan Ich habe nichts getan, nur einen EditText zur App hinzugefügt und versuche zu laufen .. Und es kompiliert ohne Fehler oder Warnungen, aber wenn versuchen, auf dem Gerät zu zeigen, schließt es und ich zeige den Fehler, den ich erwähnt habe zu diesem Thema – Gorio

+0

Ich habe mit genau dem gleichen Problem zu kämpfen. Und ich betreibe Android Studio 2.2 unter Linux, genau wie du, denke ich. – Rames

Antwort

32

Nach einem echten Kampf, dies scheint ein gradle Problem. Downgradle Gradle von 2.2.0-Alpha1 zu einer stabilen Version (2.1 funktionierte für mich).

So ändern build.gradle (App-Ebene) und Sync:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.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 
} 
+0

Gibt es einen Bug auf Android-Tracker geöffnet? Ich würde gerne sehen, dass dies in der nächsten Veröffentlichung gelöst wird. –

+6

UPDATE: hier ist es https://code.google.com/p/android/issues/detail?id=210467 –

+2

2.2.0-alpha4 sollte in ein oder zwei Tagen aus sein und es wird behauptet, dass die enthalten beheben dafür. –

1

Dieser Zusammenhang scheint, aber ich hatte ein Problem, wo die edittexts wurden zu einem Absturz auf dem Samsung Tab verursacht 4, aber schien gut zu funktionieren auf jedem anderen Gerät. Schließlich entdeckte ich, dass die /res/drawable-v21/abc_edit_text_material.xml fehlte, also nahm ich abc_edit_text_material.xml von der vorherigen sdk und fügte mein Projekt hinzu, bis alle Fehler aus den kommenden Gradle-Plugins ausgearbeitet wurden.

1

Keine Notwendigkeit für Downgradle Erstellen Sie einfach eine Unterklasse, die EditText erweitert. Beispiel:

public class Text extends EditText { 
    public Text(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 
} 

Dann diese Klasse in XML-Datei verwenden instaed von EditText

<com.example.edittextproblem.Text 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="haha"/> 

und Ihr Problem gelöst werden :)

Verwandte Themen