2013-04-08 97 views
3

嗨,我创建了我的第一个Hello World应用程序,并遵循指示 张贴在developer.android,但当我连接我的索尼xperia s与 调试启用并运行我的应用程序,我看到在logcat的错误说法 “E /(4446):无法打开文件进行读取”我使用的ADT插件 Eclipse的android无法打开文件阅读

package com.example.myfirstapp; 
import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
public class MyMainActivity extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_my_main); 
    } 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.activity_my_main, menu); 
     return true; 
    } 
} 
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.myfirstapp" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 
    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.myfirstapp.MyMainActivity" 
      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> 

<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" 
    tools:context=".MyMainActivity" > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="@string/hello_world" /> 

</RelativeLayout> 

任何想法,请什么造成了“无法打开文件”的错误感谢你的 为你的支持提供完整的logcat栈

04-08 12:20:07.350: D/TextLayoutCache(4446): Using debug level: 0 - Debug Enabled: 0 
04-08 12:20:07.420: D/libEGL(4446): loaded /system/lib/egl/libGLES_android.so 
04-08 12:20:07.420: D/libEGL(4446): loaded /system/lib/egl/libEGL_adreno200.so 
04-08 12:20:07.430: D/libEGL(4446): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 
04-08 12:20:07.440: D/libEGL(4446): loaded /system/lib/egl/libGLESv2_adreno200.so 
04-08 12:20:07.460: I/Adreno200-EGLSUB(4446): <ConfigWindowMatch:2078>: Format RGBA_8888. 
04-08 12:20:07.470: D/memalloc(4446): /dev/pmem: Mapped buffer base:0x5c63d000 size:3768320 offset:0 fd:64 
04-08 12:20:07.480: E/(4446): Can't open file for reading 
04-08 12:20:07.480: E/(4446): Can't open file for reading 
04-08 12:20:07.480: D/OpenGLRenderer(4446): Enabling debug mode 0 
04-08 12:20:07.550: D/memalloc(4446): /dev/pmem: Mapped buffer base:0x5ce2c000 size:33538048 offset:29769728 fd:67 
04-08 12:20:33.110: D/OpenGLRenderer(4446): Flushing caches (mode 0) 
04-08 12:20:33.130: D/memalloc(4446): /dev/pmem: Unmapping buffer base:0x5c63d000 size:3768320 offset:0 
04-08 12:20:33.130: D/memalloc(4446): /dev/pmem: Unmapping buffer base:0x5ce2c000 size:33538048 offset:29769728 
04-08 12:20:33.140: D/OpenGLRenderer(4446): Flushing caches (mode 1) 

回答

0

当您运行应用程序时是否看到“hello world”字符串?错误中没有任何内容表明它是由您的应用程序抛出的。

+0

嗨,对不起,延迟。我确实看到了hello world,应用程序运行正常。 – 2013-04-11 21:47:05

+0

然后在大多数情况下,它不会被您的应用程序抛出。 – 2013-04-12 01:12:05

0

确保您检查了权限(读,写,...)以使用文件。