Android Studio 2.2 anteprima 1 Errore EditText

Sto cercando di utilizzare l'anteprima di Android Studio 2.2, ma se creo un nuovo progetto e aggiunto un semplice ModificaText e provo a eseguire, ho l'errore seguente.

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 

e il mio layout è

  • Comprimere automaticamente ActionBar SearchView sulla tastiera soft vicino
  • Il codice Dagger che dà NoClassDefFoundError quando Espresso Test sono eseguiti, il funzionamento normale funziona bene
  • Utilizza una notifica persistente per consentire all'utente di tornare all'applicazione Android
  • Creare in modo dinamico CheckBoxPreferences
  • Come modificare lo stile di un EditText predefinito
  • Come consumare i servizi WCF dipendenti dalla session utilizzando Ksoap2-Android
  •  <?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> 

    Il mio file build.gradle (livello del module) è

     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.express:express-core:2.2.2' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support:support-annotations:23.4.0' } 

    e il mio file build.gradle (livello di applicazione) è

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

    E questa è la mia anteprima di layout in AS 2.2 anteprima 1

    immettere qui la descrizione dell'immagine

  • Come rilevare un dispositivo tablet in Android?
  • android studio 2.3 non funziona correttamente
  • Due elementi XML con lo stesso ID
  • Come informare gli utenti di un aggiornamento di Android App?
  • Contenuti dietro CoordinatorLayout AppBarLayout
  • Imansible submit un asset a un dispositivo Android Wear
  • 3 Solutions collect form web for “Android Studio 2.2 anteprima 1 Errore EditText”

    Dopo una vera lotta, questo sembra essere un problema di gradile. Decrementa gradle da 2.2.0-alpha1 a versione stabile (2.1 ha lavorato per me).

    Modificare quindi build.gradle (livello dell'applicazione) e sincronizzare:

     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 } 

    Ciò sembra correlato, ma ho avuto un problema in cui i edittexts stava causando un incidente sul Samsung Tab 4, ma sembrava funzionare bene su each altro dispositivo. Infine scopriamo che mancava la /res/drawable-v21/abc_edit_text_material.xml , quindi ho preso abc_edit_text_material.xml dal precedente sdk e ho aggiunto al mio progetto finché tutti i bug sono stati elaborati dai prossimi plugin Gradle.

    Nessuna necessità di Downgradle Basta creare una sottocategoria che estende EditText. Per esempio:

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

    Quindi utilizzare questa class in file xml instaed di EditText

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

    e il tuo problema sarà risolto 🙂

    L'Android è un fan Android di Google, tutto su telefoni Android, Android Wear, Android Dev e applicazioni Android Games e così via.