解決方法がわからない問題が発生しました。解決方法を教えてもらえますか? 問題は、アクティビティを 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 で実装されるマップです。
Intro.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();
}
}