2017-06-20 71 views
2

我試圖用Android工作室運行我的應用程序時出現錯誤。
我試圖改變圖像,它運行正常,但是當我把我的形象它不會運行。充氣錯誤查看

這是做錯誤的圖像:

enter image description here

這是我的代碼佈局:

這是我的活動:

public class AppActivity extends ActivityBase { 

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

,這是錯誤我得到:

AndroidRuntime: FATAL EXCEPTION: main 
        java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.ifsoft.qachat/ru.ifsoft.qachat.AppActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView 
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970) 
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995) 
         at android.app.ActivityThread.access$600(ActivityThread.java:128) 
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161) 
         at android.os.Handler.dispatchMessage(Handler.java:99) 
         at android.os.Looper.loop(Looper.java:137) 
         at android.app.ActivityThread.main(ActivityThread.java:4517) 
         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:993) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) 
         at dalvik.system.NativeStart.main(Native Method) 
        Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView 
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 
         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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
         at ru.ifsoft.qachat.AppActivity.onCreate(AppActivity.java:39) 
         at android.app.Activity.performCreate(Activity.java:4470) 
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053) 
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934) 
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)  
         at android.app.ActivityThread.access$600(ActivityThread.java:128)  
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)  
         at android.os.Handler.dispatchMessage(Handler.java:99)  
         at android.os.Looper.loop(Looper.java:137)  
         at android.app.ActivityThread.main(ActivityThread.java:4517)  
         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:993)  
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)  
         at dalvik.system.NativeStart.main(Native Method)  
        Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020426 a=-1 r=0x7f020426} 
         at android.content.res.Resources.loadDrawable(Resources.java:1960) 
         at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
         at android.widget.ImageView.<init>(ImageView.java:119) 
         at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:60) 
         at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56) 
         at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106) 
         at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1021) 
         at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080) 
         at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47) 
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:668) 
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)  
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)  
         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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)  
         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
         at ru.ifsoft.qachat.AppActivity.onCreate(AppActivity.java:39)  
         at android.app.Activity.performCreate(Activity.java:4470)  
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)  
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)  
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)  
         at android.app.ActivityThread.access$600(ActivityThread.java:128)  
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)  
         at android.os.Handler.dispatchMessage(Handler.java:99)  
         at android.os.Looper.loop(Looper.java:137)  
         at android.app.ActivityThread.main(ActivityThread.java:4517)  
         at java.lang.reflect.Method.invokeNative(Native Method)  
         at java.lang.reflect.Method.invoke(Method.java:511) 
+1

在您繪製文件夾logo.png? –

+0

也檢查您的圖像文件的名稱,如果它與您在ImageView –

+0

中使用的圖像文件匹配是的,它是在我的drawable中,它通常出現在android studio佈局預覽 –

回答

0

您的設備沒有華電國際,所以當運行Android它會尋找相應的文件夾和崩潰的圖像,因爲它不能找到它。您可以

  1. 將圖像中的所有文件夾繪製LDPI,華電國際,xhdpi,MDPI,xxhdpi和xxxhdpi。

  2. 或者,你可以把它只有在 「繪製」 文件夾

    folder structure