2017-06-08 112 views
-1

這些是提到的代碼部分。當我運行這些錯誤彈出logcat文件和應用程序崩潰時打開。有這麼多,我無法弄清楚實際的錯誤在哪裏。請幫助我在哪裏因爲我正嘗試構建一個啓動畫面,所以需要進行修改和替換。我收到錯誤不幸的應用程序已停止。錯誤在哪裏?

logcat的:

06-08 11:36:18.203 17265-17265/? E/AndroidRuntime: FATAL EXCEPTION: main 
                Process: com.elvero.telecom.voipapp, PID: 17265 
                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.elvero.telecom.voipapp/com.elvero.telecom.voipapp.splash}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView 
                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567) 
                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641) 
                 at android.app.ActivityThread.access$800(ActivityThread.java:182) 
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) 
                 at android.os.Handler.dispatchMessage(Handler.java:111) 
                 at android.os.Looper.loop(Looper.java:194) 
                 at android.app.ActivityThread.main(ActivityThread.java:5717) 
                 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:959) 
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
                Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView 
                 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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                 at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13) 
                 at android.app.Activity.performCreate(Activity.java:6092) 
                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 
                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514) 
                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)  
                 at android.app.ActivityThread.access$800(ActivityThread.java:182)  
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)  
                 at android.os.Handler.dispatchMessage(Handler.java:111)  
                 at android.os.Looper.loop(Looper.java:194)  
                 at android.app.ActivityThread.main(ActivityThread.java:5717)  
                 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:959)  
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)  
                Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x6 
                 at android.content.res.TypedArray.getDimensionPixelOffset(TypedArray.java:533) 
                 at android.view.View.<init>(View.java:3927) 
                 at android.widget.ImageView.<init>(ImageView.java:139) 
                 at android.widget.ImageView.<init>(ImageView.java:135) 
                 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:1029) 
                 at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087) 
                 at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47) 
                 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.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)  
                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
                 at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13)  
                 at android.app.Activity.performCreate(Activity.java:6092)  
                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)  
                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)  
                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)  
                 at android.app.ActivityThread.access$800(ActivityThread.java:182)  
                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)  
                 at android.os.Handler.dispatchMessage(Handler.java:111)  
                 at android.os.Looper.loop(Looper.java:194)  
                 at android.app.ActivityThread.main(ActivityThread.java:5717)  
                 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:959)  
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)  
06-08 11:36:22.207 17265-17265/? I/Process: Sending signal. PID: 17265 SIG: 9 

MainActivity.java:

package com.elvero.telecom.voipapp; 

import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.support.v7.app.ActionBarActivity; 


public class MainActivity extends AppCompatActivity { 
    private Toolbar toolbar; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     toolbar= (Toolbar)findViewById(R.id.app_bar); 
     setSupportActionBar(toolbar); 

    } 
} 

的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.elvero.telecom.voipapp"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:roundIcon="@mipmap/ic_launcher_round" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity android:name=".MainActivity"> 

     </activity> 

     <activity android:name=".splash"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

</manifest> 

splashactivity:

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 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" 
     android:visibility="visible" 
     tools:context="com.elvero.telecom.voipapp.splash"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:background="@android:color/holo_blue_light" 
      android:elevation="@android:dimen/dialog_min_width_minor" 
      android:scaleType="fitCenter" 
      android:src="@drawable/logo_elvero"/> 
     </RelativeLayout> 

Splash.java:

package com.elvero.telecom.voipapp; 

import android.content.Intent; 
import android.os.Handler; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class splash extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash); 
     Handler handler=new Handler(); 
     handler.postDelayed(new Runnable(){ 
      @Override 
      public void run(){ 
       startActivity(new Intent(splash.this,MainActivity.class)); 
       finish(); 

      } 
     },1000); 
    } 
} 
+0

爲XML activity_main – Nidhi

+0

你能只保留必要的東西在你的ImageView添加代碼?棧跟蹤說錯誤膨脹類ImageView只是保持src和大小attrribut其餘的測試目的丟棄 – Timo

+0

你的imageview在xml中的問題 – jagapathi

回答

0

您可以單獨活動的啓動畫面,並使用下面的代碼的onCreate(),以顯示它所需秒鐘,然後可以移動到主着陸活動。

new CountDownTimer(2000, 1000) { 
     public void onTick(long millisUntilFinished) { 
     } 
     public void onFinish() { 
      HarmUtils.openActivity(SplashScreenActivity.this, LoginActivity.class, true); 
     } 
    }.start(); 

這裏2000是等待時間(2000 = 2秒),第二個參數是我設置爲1秒的時間間隔。 您可以根據您的要求指定您的時間。

希望這會幫助你。造成

1

錯誤,因爲代碼

android:elevation="@android:dimen/dialog_min_width_minor" 

它能夠更好地給予直接價值,它像

android:elevation="5dp" 
相關問題