1

因此,我正在创建一个显示 googlemap 的简单应用程序。我没有项目错误,但不幸的是“应用程序”已停止错误。

这是我的日志猫

10-29 13:10:00.916: D/AndroidRuntime(458): Shutting down VM
10-29 13:10:00.916: W/dalvikvm(458): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
10-29 13:10:00.936: E/AndroidRuntime(458): FATAL EXCEPTION: main
10-29 13:10:00.936: E/AndroidRuntime(458): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bossapps.campusmapped/com.bossapps.campusmapped.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.os.Looper.loop(Looper.java:137)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread.main(ActivityThread.java:4340)
10-29 13:10:00.936: E/AndroidRuntime(458):  at java.lang.reflect.Method.invokeNative(Native Method)
10-29 13:10:00.936: E/AndroidRuntime(458):  at java.lang.reflect.Method.invoke(Method.java:511)
10-29 13:10:00.936: E/AndroidRuntime(458):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-29 13:10:00.936: E/AndroidRuntime(458):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-29 13:10:00.936: E/AndroidRuntime(458):  at dalvik.system.NativeStart.main(Native Method)
10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.createView(LayoutInflater.java:606)
10-29 13:10:00.936: E/AndroidRuntime(458):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-29 13:10:00.936: E/AndroidRuntime(458):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.Activity.setContentView(Activity.java:1835)
10-29 13:10:00.936: E/AndroidRuntime(458):  at com.bossapps.campusmapped.MainActivity.onCreate(MainActivity.java:12)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.Activity.performCreate(Activity.java:4465)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
10-29 13:10:00.936: E/AndroidRuntime(458):  ... 11 more
10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: java.lang.reflect.InvocationTargetException
10-29 13:10:00.936: E/AndroidRuntime(458):  at java.lang.reflect.Constructor.constructNative(Native Method)
10-29 13:10:00.936: E/AndroidRuntime(458):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.LayoutInflater.createView(LayoutInflater.java:586)
10-29 13:10:00.936: E/AndroidRuntime(458):  ... 23 more
10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f050000 a=-1 r=0x7f050000}
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.content.res.Resources.loadDrawable(Resources.java:1899)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.View.<init>(View.java:2780)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.View.<init>(View.java:2717)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.view.ViewGroup.<init>(ViewGroup.java:379)
10-29 13:10:00.936: E/AndroidRuntime(458):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:174)
10-29 13:10:00.936: E/AndroidRuntime(458):  ... 26 more

有人有想法么?

编辑:请记住,我只添加了一些虚拟按钮来测试它基本上是一个全新的应用程序。除了按钮之外,我创建的唯一东西是保存按钮上显示的字符串的字符串变量,除此之外它是一个全新的应用程序。

这是我的 MainActivity.java

package com.bossapps.campusmapped;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

在 API 版本 16 AVD 上运行

XML 活动主文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@style/AppTheme" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="14dp"
        android:text="@string/Welcome"
        tools:context=".MainActivity" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:text="@string/View_Mode"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <RadioButton
        android:id="@+id/radioButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="23dp"
        android:text="@string/Regular" />

    <RadioButton
        android:id="@+id/radioButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/radioButton1"
        android:layout_below="@+id/radioButton1"
        android:text="@string/Augmented " />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/radioButton2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="33dp"
        android:text="@string/Go" />

</RelativeLayout>
4

3 回答 3

3

你检查过你有一个Appthemein@style/Apptheme吗?因为它是解析器找不到的唯一资源(即:)not a drawable (color or path)

10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: 
  android.content.res.Resources$NotFoundException: Resource is not a Drawable 
  (color or path): TypedValue{t=0x1/d=0x7f050000 a=-1 r=0x7f050000}
于 2012-10-29T16:43:44.683 回答
0

从您的跟踪中猜测,您的 xml 布局有问题.... android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout。

你能发帖吗?

于 2012-10-29T16:02:02.533 回答
0
 10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: android.view.InflateException:     Binary XML file line #1: Error inflating class android.widget.RelativeLayout

 10-29 13:10:00.936: E/AndroidRuntime(458): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f050000 a=-1 r=0x7f050000}

一些Drawable在一些RelativeLayoutMainActivity setContentView()方法?

于 2012-10-29T16:08:12.550 回答