2016-06-29 20 views
3

奇妙な問題が発生しました。私がEditTextActivityに追加すると、私のAndroidアプリはクラッシュします。テストするために、新しいクリーンプロジェクトを開きます。EditTextがある場合は、新しいプロジェクトがクラッシュします。したがって、問題はAndroid Studioやその他の環境設定によって発生していると思います。続いAndroid Error inflating class EditText

はactivity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    android:id="@+id/activity_main" 
    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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="yichun.myapplication.MainActivity"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" 
     android:id="@+id/textView" 
     app:layout_constraintLeft_toLeftOf="@+id/activity_main" 
     app:layout_constraintTop_toTopOf="@+id/activity_main" 
     app:layout_constraintRight_toRightOf="@+id/activity_main" 
     app:layout_constraintBottom_toBottomOf="@+id/activity_main"/> 
    <EditText 
     android:layout_width="218dp" 
     android:layout_height="45dp" 
     android:inputType="textPersonName" 
     android:text="Name" 
     android:ems="10" 
     tools:layout_editor_absoluteX="90dp" 
     android:id="@+id/editText" 
     app:layout_constraintBottom_toTopOf="@+id/textView" android:layout_marginBottom="40dp"/> 
</android.support.constraint.ConstraintLayout> 

MainActivity.java パブリッククラスMainActivityがAppCompatActivity {

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 
} 

のAndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 

を延びています
<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 

      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 
</application> 

エラーメッセージのGradleプラグインの2.2.xのバージョンを使用して

E/AndroidRuntime: FATAL EXCEPTION: main 
       Process: yichun.myapplication, PID: 3239 
       java.lang.RuntimeException: Unable to start activity ComponentInfo{yichun.myapplication/yichun.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class EditText 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
        at android.app.ActivityThread.access$800(ActivityThread.java:144) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5221) 
        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:899) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
       Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class EditText 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11) 
        at android.app.Activity.performCreate(Activity.java:5937) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  
        at android.app.ActivityThread.access$800(ActivityThread.java:144)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  
        at android.os.Handler.dispatchMessage(Handler.java:102)  
        at android.os.Looper.loop(Looper.java:135)  
        at android.app.ActivityThread.main(ActivityThread.java:5221)  
        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:899)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  
       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:2428) 
        at android.content.res.Resources.loadDrawable(Resources.java:2330) 
        at android.content.res.TypedArray.getDrawable(TypedArray.java:749) 
        at android.view.View.<init>(View.java:3730) 
        at android.widget.TextView.<init>(TextView.java:634) 
        at android.widget.EditText.<init>(EditText.java:65) 
        at android.widget.EditText.<init>(EditText.java:61) 
        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:725) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)  
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
        at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11)  
        at android.app.Activity.performCreate(Activity.java:5937)  
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)  
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)  
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  
        at android.app.ActivityThread.access$800(ActivityThread.java:144)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  
        at android.os.Handler.dispatchMessage(Handler.java:102)  
        at android.os.Looper.loop(Looper.java:135)  
        at android.app.ActivityThread.main(ActivityThread.java:5221)  
        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:899)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  
       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:1095) 
        at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:185) 
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095) 
        at android.graphics.drawable.InsetDrawable.inflate(InsetDrawable.java:104) 
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095) 
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1017) 
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2418) 
        at android.content.res.Resources.loadDrawable(Resources.java:2330)  
        at android.content.res.TypedArray.getDrawable(TypedArray.java:749)  
        at android.view.View.<init>(View.java:3730)  
        at android.widget.TextView.<init>(TextView.java:634)  
        at android.widget.EditText.<init>(EditText.java:65)  
        at android.widget.EditText.<init>(EditText.java:61)  
        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:725)  
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)  
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)  
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
        at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11)  
        at android.app.Activity.performCreate(Activity.java:5937)  
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)  
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)  
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  
        at android.app.ActivityThread.access$800(ActivityThread.java:144)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  
        at android.os.Handler.dispatchMessage(Handler.java:102)  
        at android.os.Looper.loop(Looper.java:135)  
        at android.app.ActivityThread.main(ActivityThread.java:5221)  
        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:899)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  
+1

'リソース$ NotFoundExceptionをダウングレードしてみてくださいres/drawable-v21/abc_edit_text_material.xml'あなたが使用しているテーマを確認してください。 – Vucko

+0

あなたのアクティビティテーマでは、おそらく存在しない編集テキストのテーマを設定しています –

答えて

4

はこれを引き起こす可能性があります。

試してみる価値かもしれないのダウングレード

Bug tracker link

:ファイル:

// this is your project level build.gradle 
dependencies { 
    classpath 'com.android.tools.build:gradle:2.1.0' 
} 

私はそれが最終的に固定されると仮定し、その将来の読者は、アップグレードの代わりに:)

+0

ありがとう!ダウングレードは私のために働く! – jackykuo

関連する問題