我对我正在制作的应用程序有疑问。当手机进入暂停状态时,应用程序将关闭并显示我不明白的logcat中的错误列表。非常感谢你的任何帮助或建议。
以下是代码:
layout0.xml --->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fondo" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/imageView_reto_simple"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_weight="1"
android:onClick="reto_simple_Click"
android:src="@drawable/icono_entrenar_normal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIMPLE"
android:layout_gravity="center"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#FFFFFF" />
</LinearLayout>
Layout0Activty.class ---&gt;
package com.example.experiment;
import android.media.AudioManager;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
public class Layout0Activity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//carregue el layout0
setContentView(R.layout.layout0);
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
public void reto_simple_Click(View v){
}
}
Android Manifest - &gt;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.experiment"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.example.experiment.Layout0Activity"
android:screenOrientation="landscape"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat - &gt;
04-13 22:30:29.947: W/ResourceType(13922): Failure getting entry for 0x7f030000 (t=2 e=0) in package 0 (error -75)
04-13 22:30:29.947: D/AndroidRuntime(13922): Shutting down VM
04-13 22:30:29.947: W/dalvikvm(13922): threadid=1: thread exiting with uncaught exception (group=0x40c3c1f8)
04-13 22:30:29.982: E/AndroidRuntime(13922): FATAL EXCEPTION: main
04-13 22:30:29.982: E/AndroidRuntime(13922): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.experiment/com.example.experiment.Layout0Activity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3363)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.access$700(ActivityThread.java:127)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1163)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.os.Handler.dispatchMessage(Handler.java:99)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.os.Looper.loop(Looper.java:137)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.main(ActivityThread.java:4507)
04-13 22:30:29.982: E/AndroidRuntime(13922): at java.lang.reflect.Method.invokeNative(Native Method)
04-13 22:30:29.982: E/AndroidRuntime(13922): at java.lang.reflect.Method.invoke(Method.java:511)
04-13 22:30:29.982: E/AndroidRuntime(13922): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-13 22:30:29.982: E/AndroidRuntime(13922): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-13 22:30:29.982: E/AndroidRuntime(13922): at dalvik.system.NativeStart.main(Native Method)
04-13 22:30:29.982: E/AndroidRuntime(13922): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.content.res.Resources.getValue(Resources.java:1019)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.content.res.Resources.getLayout(Resources.java:858)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-13 22:30:29.982: E/AndroidRuntime(13922): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:271)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.Activity.setContentView(Activity.java:1835)
04-13 22:30:29.982: E/AndroidRuntime(13922): at com.example.experiment.Layout0Activity.onCreate(Layout0Activity.java:20)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.Activity.performCreate(Activity.java:4465)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
04-13 22:30:29.982: E/AndroidRuntime(13922): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
04-13 22:30:29.982: E/AndroidRuntime(13922): ... 12 more
答案 0 :(得分:1)
尝试重命名没有数字的布局。
答案 1 :(得分:0)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000.
您的gen / R.java文件中为该值分配了哪些资源?我怀疑它是R.layout.layout0,因为这也是分配给我项目的第一个活动的值。
我赞同Allel的回答,因为这也是我所怀疑的。我过去曾经有过一些关于资源文件名中数字的构建警告。
另外,尝试进行“清理”构建。我通常从Eclipse(Project - &gt; Clean ...)执行此操作,但它几乎等同于删除“gen”和“bin”目录并再次构建。
唯一可能的是你的“drawable”(icono_entrenar_normal)。确保在“res / drawable”目录中有一个icono_entrenar_normal.png文件(即使你的布局特定的drawable-NNN目录中有一个副本)。
答案 2 :(得分:0)
我已经解决了这个问题。在我的项目中,我在android清单中的layout-land文件夹中有布局,我有与android属性相关的布局活动:screenOrientation =“landscape”。我想我有两次同样的事情。我重命名了文件夹布局 - 土地布局......问题消失了! .....谢谢大家,我希望如果有人有同样的问题......这会有所帮助......