エミュレータとデバイスで一貫性のないInflate例外が発生しますが、正常に動作する場合があります
xmlの-16行目で、問題が発生していることを示しています。2つの画像を上下に使用しています。
私はビットマップ画像を持っていて、その下に.png画像を保持しました。
これは私がxmlに持っている画像のベコズですか?ほぼ私は私のxmlに10の画像を持っています
私はこのアプリケーションを800クロス480解像度のエミュレーターで実行しています
私はこれを修正する方法を知りません、どんな助けでも常にありがたいです。
これらのメッセージを表示するLogcat
10-09 09:39:34.667: E/AndroidRuntime(339): FATAL EXCEPTION: main
10-09 09:39:34.667: E/AndroidRuntime(339): java.lang.RuntimeException: Unable to start activity ComponentInfo{co.msat.carhome.clusters/co.msat.carhome.clusters.ClustersActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.os.Looper.loop(Looper.java:123)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-09 09:39:34.667: E/AndroidRuntime(339): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 09:39:34.667: E/AndroidRuntime(339): at java.lang.reflect.Method.invoke(Method.java:507)
10-09 09:39:34.667: E/AndroidRuntime(339): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-09 09:39:34.667: E/AndroidRuntime(339): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-09 09:39:34.667: E/AndroidRuntime(339): at dalvik.system.NativeStart.main(Native Method)
10-09 09:39:34.667: E/AndroidRuntime(339): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-09 09:39:34.667: E/AndroidRuntime(339): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-09 09:39:34.667: E/AndroidRuntime(339): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.Activity.setContentView(Activity.java:1657)
10-09 09:39:34.667: E/AndroidRuntime(339): at co.msat.carhome.clusters.ClustersActivity.onCreate(ClustersActivity.java:53)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-09 09:39:34.667: E/AndroidRuntime(339): ... 11 more
10-09 09:39:34.667: E/AndroidRuntime(339): Caused by: java.lang.reflect.InvocationTargetException
10-09 09:39:34.667: E/AndroidRuntime(339): at java.lang.reflect.Constructor.constructNative(Native Method)
10-09 09:39:34.667: E/AndroidRuntime(339): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-09 09:39:34.667: E/AndroidRuntime(339): ... 22 more
10-09 09:39:34.667: E/AndroidRuntime(339): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f070001}
10-09 09:39:34.667: E/AndroidRuntime(339): at android.content.res.Resources.loadDrawable(Resources.java:1681)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.view.View.<init>(View.java:1951)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.widget.ImageView.<init>(ImageView.java:112)
10-09 09:39:34.667: E/AndroidRuntime(339): at android.widget.ImageView.<init>(ImageView.java:108)
10-09 09:39:34.667: E/AndroidRuntime(339): ... 25 more
10-09 09:44:34.836: I/Process(339): Sending signal. PID: 339 SIG: 9
10-09 09:54:16.536: D/AndroidRuntime(368): Shutting down VM
10-09 09:54:16.536: W/dalvikvm(368): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-09 09:54:16.667: E/AndroidRuntime(368): FATAL EXCEPTION: main
10-09 09:54:16.667: E/AndroidRuntime(368): java.lang.RuntimeException: Unable to start activity ComponentInfo{co.msat.carhome.clusters/co.msat.carhome.clusters.ClustersActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.os.Looper.loop(Looper.java:123)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-09 09:54:16.667: E/AndroidRuntime(368): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 09:54:16.667: E/AndroidRuntime(368): at java.lang.reflect.Method.invoke(Method.java:507)
10-09 09:54:16.667: E/AndroidRuntime(368): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-09 09:54:16.667: E/AndroidRuntime(368): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-09 09:54:16.667: E/AndroidRuntime(368): at dalvik.system.NativeStart.main(Native Method)
10-09 09:54:16.667: E/AndroidRuntime(368): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-09 09:54:16.667: E/AndroidRuntime(368): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-09 09:54:16.667: E/AndroidRuntime(368): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.Activity.setContentView(Activity.java:1657)
10-09 09:54:16.667: E/AndroidRuntime(368): at co.msat.carhome.clusters.ClustersActivity.onCreate(ClustersActivity.java:53)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-09 09:54:16.667: E/AndroidRuntime(368): ... 11 more
10-09 09:54:16.667: E/AndroidRuntime(368): Caused by: java.lang.reflect.InvocationTargetException
10-09 09:54:16.667: E/AndroidRuntime(368): at java.lang.reflect.Constructor.constructNative(Native Method)
10-09 09:54:16.667: E/AndroidRuntime(368): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-09 09:54:16.667: E/AndroidRuntime(368): ... 22 more
10-09 09:54:16.667: E/AndroidRuntime(368): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f070001}
10-09 09:54:16.667: E/AndroidRuntime(368): at android.content.res.Resources.loadDrawable(Resources.java:1681)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.view.View.<init>(View.java:1951)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.widget.ImageView.<init>(ImageView.java:112)
10-09 09:54:16.667: E/AndroidRuntime(368): at android.widget.ImageView.<init>(ImageView.java:108)
10-09 09:54:16.667: E/AndroidRuntime(368): ... 25 more
これは私のxmlコードです
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_ph"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/meter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="110dip"
android:layout_marginTop="80dip"
android:src="@drawable/background" />
<ImageView
android:id="@+id/pointer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="110dip"
android:layout_marginTop="80dip"
android:background="@+id/meter"
android:visibility="visible" />
<!--
android:layout_gravity="left"
android:layout_marginLeft="170dip"
android:layout_marginTop="100dip"
android:src="@drawable/meat_speedometer_needle01"
-->
<ImageView
android:id="@+id/rpm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="290dip"
android:layout_marginTop="80dip"
android:src="@drawable/background" />
<ImageView
android:id="@+id/pointer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="290dip"
android:layout_marginTop="80dip"
android:background="@+id/rpm"
android:visibility="visible" />
<TableLayout
android:layout_width="fill_parent"
android:layout_height="60dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/text1"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="50dip"
android:layout_marginTop="30dp"
android:background="@drawable/leftarrow"
android:textSize="10dp" />
<TextView
android:id="@+id/text2"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="170dip"
android:layout_marginTop="30dp"
android:background="#ff0000"
android:textSize="10dp" />
<ImageView
android:id="@+id/rightindicator"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="180dip"
android:layout_marginTop="30dp"
android:background="@drawable/rightarrow"
android:textSize="10dp" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="90dp"
android:layout_gravity="bottom" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/text11"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="50dip"
android:layout_marginTop="0dp"
android:background="@drawable/icon" />
<TextView
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp"
android:text="30'C" />
<ImageView
android:id="@+id/text12"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="120dip"
android:layout_marginTop="30dp"
android:background="@drawable/battery"
android:textSize="10dp" />
<TextView
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="30dp"
android:text="70%" />
<ImageView
android:id="@+id/text13"
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="105dip"
android:layout_marginTop="30dp"
android:background="@drawable/fuel"
android:textSize="10dp" />
<TextView
android:layout_width="30dp"
android:layout_height="20dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="30dp"
android:text="25L" />
</TableRow>
</TableLayout>
これは私のJavaコードです
public class ClustersActivity extends Activity {
/** Called when the activity is first created. */
// ViewFlipper vf;
ImageView img, img1, rightindicator, pointer1, pointer2;
Bitmap bitmap;
Matrix matrix = new Matrix();
private IMyRemoteService remoteService;
private boolean started = false;
private RemoteServiceConnection conn = null;
private Handler serviceHandler;
private int enginRPM;
private int batteryLevel;
private int temperature;
private static int speed;
private Task myTask = new Task();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.cluster);
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
startService();
bindService();
System.gc();
bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.meat_speedometer_needle01);
rightindicator = (ImageView) findViewById(R.id.rightindicator);
img = (ImageView) findViewById(R.id.meter);
img1 = (ImageView) findViewById(R.id.rpm);
pointer1 = (ImageView) findViewById(R.id.pointer1);
pointer1.setImageBitmap(bitmap);
pointer1.setScaleType(ScaleType.CENTER);
pointer1.setVisibility(View.VISIBLE);
pointer2 = (ImageView) findViewById(R.id.pointer2);
pointer2.setImageBitmap(bitmap);
pointer2.setScaleType(ScaleType.CENTER);
pointer2.setVisibility(View.VISIBLE);
final Animation fadein = AnimationUtils.loadAnimation(this,
R.anim.fade_in);
final Animation fadeout = AnimationUtils.loadAnimation(this,
R.anim.fade_out);
// rightindicator.startAnimation(animationScale);
rightindicator.startAnimation(fadein);
rightindicator.startAnimation(fadeout);
serviceHandler = new Handler();
serviceHandler.postDelayed(myTask, 1000L);
}