0

我遇到了一个我不知道如何解决的问题,有人可以解释一下如何解决吗?我认为问题在于将活动链接到 Mapactivity.. 为什么?因为我的 android 应用程序之前运行良好,只有 MapActivity,现在当我尝试向我的应用程序添加更多内容时,它无法运行应用程序并在我的 samsung Galaxy s4 上显示错误“不幸的是,LCidadao 已停止。”

05-18 22:18:53.212: D/skia(23942): ---- fAsset->read(2074) returned 0
05-18 22:18:53.252: W/ResourceType(23942): Bad XML block: header size 18254 or total size 169478669 is larger than data size 6480
05-18 22:18:53.252: D/AndroidRuntime(23942): Shutting down VM
05-18 22:18:53.252: W/dalvikvm(23942): threadid=1: thread exiting with uncaught exception (group=0x40fa1ac8)
05-18 22:18:53.252: E/AndroidRuntime(23942): FATAL EXCEPTION: main
05-18 22:18:53.252: E/AndroidRuntime(23942): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.basicmaponline/com.example.basicmaponline.Intro}: android.content.res.Resources$NotFoundException: File res/drawable/intro.png from xml type layout resource ID #0x7f020001
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread.access$700(ActivityThread.java:151)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.os.Looper.loop(Looper.java:137)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread.main(ActivityThread.java:5293)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at java.lang.reflect.Method.invokeNative(Native Method)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at java.lang.reflect.Method.invoke(Method.java:511)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at dalvik.system.NativeStart.main(Native Method)
05-18 22:18:53.252: E/AndroidRuntime(23942): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/intro.png from xml type layout resource ID #0x7f020001
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:3083)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:3030)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.Resources.getLayout(Resources.java:1722)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.Activity.setContentView(Activity.java:1928)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at com.example.basicmaponline.Intro.onCreate(Intro.java:13)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.Activity.performCreate(Activity.java:5250)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
-18 22:18:53.252: E/AndroidRuntime(23942):  ... 11 more
05-18 22:18:53.252: E/AndroidRuntime(23942): Caused by: java.io.FileNotFoundException: Corrupt XML binary file
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.AssetManager.openXmlAssetNative(Native Method)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:487)
05-18 22:18:53.252: E/AndroidRuntime(23942):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:3061)
05-18 22:18:53.252: E/AndroidRuntime(23942):    ... 21 more

我的manifste.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.basicmaponline"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/lojacidadao"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.basicmaponline.Intro"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name="com.example.basicmaponline.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.basicmaponline.MAINACTIVITY" />

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

</manifest>

我的 Intro.java(扩展 Activity)是应用程序的介绍,而我的 Main_activity.java(扩展 MapActivity)是使用 mapsforge .jar 实现的地图。

介绍.java:

package com.example.basicmaponline;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Intro extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.drawable.intro);

    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);
            }catch (InterruptedException e) {
                // TODO: handle exception
                e.printStackTrace();
            }finally{
                /*Which activity will it run after doing these codes*/
                /*"com.example.testesdz.MAINACTIVITY" ver AndroidManifest.xml   , está relacionado com uma Activity (class neste caso)*/
                Intent openMainActivity = new Intent("com.example.basicmaponline.MAINACTIVITY"); //isto vem do ficheiro AndroidManifest.xml o "com.example....."
                startActivity(openMainActivity);
            }
        }
    };
    timer.start();
}
@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    //ourSong.release(); //release the music and we are done with you
    finish();
}

}
4

1 回答 1

0

找不到文件 res/drawable/intro.png。如果项目中有文件,请清理并刷新项目。有时 R.java 没有正确刷新

更新

改变

setContentView(R.drawable.intro);

setContentView(R.layout.intro);
于 2013-05-18T21:46:28.300 回答