我还是Android应用程序开发的新手,现在我偶然发现这次崩溃无法修复
清单文件详情
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.outsource.ecg"
android:versionCode="1"
android:versionName="0.1" >
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ecg_mobile"
android:label="@string/ecg_client_title" >
<activity
android:name="com.outsource.ecg.app.MainActivity"
android:label="@string/ecg_client_title"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.outsource.ecg.app.RTEcgChartActivity"
android:label="@string/rt_ecg_chart_title"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.outsource.ecg.app.EcgLoadHistoryActivity"
android:label="@string/load_user_history_title"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.outsource.ecg.app.DeviceListActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/select_device"
android:screenOrientation="portrait"/>
<activity
android:name="com.outsource.ecg.app.EcgUserManageActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/user_manager_title"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.outsource.ecg.ECG_MANAGER_MANAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.outsource.ecg.app.CreateNewUserActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/new_user_title"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.outsource.ecg.ECG_NEW_USER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.outsource.ecg.app.EcgUserHistroyRecordActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/view_histroy_records_title"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.outsource.ecg.VIEW_HISTORY_RECORDS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="com.outsource.ecg.app.SDcardMountReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<action android:name="android.intent.action.MEDIA_UNMOUNTED" />
<action android:name="android.intent.action.MEDIA_SCANNER_STARTED" />
<action android:name="android.intent.action.MEDIA_REMOVED" />
<action android:name="android.intent.action.MEDIA_BAD_REMOVAL" />
<data android:scheme="file" />
</intent-filter>
</receiver>
</application>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
</manifest>
任何人都可以帮我解决这个问题。它是如此沮丧,因为我看不出哪里可以出错。 应用程序的要点是将ecg信号发送到应用程序,绘制并存储它 ***编辑:添加appEntryAdapter
public static class AppEntryAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context mContext;
private ArrayList<AppEntry> mAppEntries;
public AppEntryAdapter(Context context, ArrayList<AppEntry> entries) {
mContext = context;
mAppEntries = entries;
mInflater = LayoutInflater.from(context);
}
这是mainActivity中的第137和138行
final AppEntry entry = mAppEntries.get(arg0);
appButton.setText(mContext.getString(entry.displayNameResID()));
_ --------------------------------------- ---------------- R.string:
public static final class string {
public static final int ID_label=0x7f040032;
String.xml
<?xml version="1.0" encoding="utf-8"?>
<string name="app_name">EcgMobile</string>
<string name="about_app">About ECG Mobile</string>
<string name="app_info">ECG Mobile\nDeveloped by:chv960@mail.usask.ca</string>
<string name="bt_not_enabled_leaving">Bluetooth is not enabled, exit!</string>
<!-- Options Menu -->
<string name="secure_connect">Connect a device - Secure</string>
<string name="insecure_connect">Connect a device - Insecure</string>
<string name="discoverable">Make bluetooth discoverable</string>
<!-- DeviceListActivity -->
<string name="scanning">scanning for devices...</string>
<string name="select_device">select a device to connect</string>
<string name="none_paired">No devices have been paired</string>
<string name="none_found">No devices found</string>
<string name="title_paired_devices">Paired Devices</string>
<string name="title_other_devices">Other Available Devices</string>
<string name="button_scan">Scan for devices</string>
<string name="title_connecting">connecting...</string>
<string name="title_connected_to">connected to </string>
<string name="title_not_connected">not connected</string>
<string name="not_connected">You are not connected to a device</string>
<!-- ECG control buttons -->
<string name="start_label">Start</string>
<string name="stop_label">Stop</string>
<string name="save_label">Save</string>
<string name="load_label">Load</string>
<string name="select">Select</string>
<string name="delete">Delete</string>
<string name="send">Send</string>
<!-- ECG user prompts -->
<string name="external_storage_unmounted_prompt">Please ensure external storage(such as SDCard) is mounted! :)</string>
<!-- Strings for Test -->
<string name="test_connection_status">Status:Disconnected</string>
<!-- Strings for Adding new ECGUser -->
<string name="add_user">New User</string>
<string name="name_label">Name:</string>
<string name="birth_label">Birth:</string>
<string name="commit_new_user_info">Save</string>
<!-- Strings for Titles -->
<string name="user_manager_title">ECGUser Management</string>
<string name="new_user_title">Create a new ECGUser</string>
<string name="view_histroy_records_title">History ECG Records</string>
<string name="ecg_server_title">ECG Mobile Server</string>
<string name="ecg_client_title">ECG Mobile Control Center</string>
<string name="load_user_history_title">ECG User History/string>
<string name="rt_ecg_chart_title">Realtime ECG Chart</string>
<!-- Connection Status -->
<string name="connected">Status:\nConnected</string>
<string name="connecting">Status:\nDisconnected</string>
<string name="none">Status:\nDisconnected</string>
<string name="listen">Status:\nListening</string>
<string name="name_item_empty">Name is empty, please retry!</string>
<string name="create_new_user_failed">Create new user failed!</string>
<string name="male_label">male</string>
<string name="female_label">female</string>
<string name="select_valid_user">Please select a valid ecg user!</string>
<string name="not_recv_any_data">Don\'t have received any valid data, do nothing!</string>
<string name="new_user_created_debug">A new user record was created!</string>
<string name="target_device_not_connected">Target device is not connected!</string>
<string name="ID_label">ID:</string><string name="gender_label">gender:</string>
<string name="enroll_date_label">Enroll Date:</string>
<string name="age_label">Age:</string>
<string name="ecg_data_path_label">ECG DataPath:</string>
<string name="hbr_label">HBR:</string>
<string name="load_history_entry">View User History Record</string>
<string name="rt_ecg_chart">Realtime ECG Chart</string></string>
--------------- appEntryAdapter的getview
public View getView(int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
ViewGroup app_entry = (ViewGroup) mInflater.inflate(
R.layout.app_entry_item, null);
Button appButton = (Button) app_entry.findViewById(R.id.app);
final AppEntry entry = mAppEntries.get(arg0);
appButton.setText(mContext.getResources().getString(R.string.load_history_entry));
08-12 15:01:59.763: W/ResourceType(622): Failure getting entry for 0x7f040038 (t=3 e=56) in package 0 (error -75)
08-12 15:01:59.763: D/AndroidRuntime(622): Shutting down VM
08-12 15:01:59.772: W/dalvikvm(622): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-12 15:01:59.782: E/AndroidRuntime(622): FATAL EXCEPTION: main
08-12 15:01:59.782: E/AndroidRuntime(622): android.content.res.Resources$NotFoundException: String resource ID #0x7f040038
08-12 15:01:59.782: E/AndroidRuntime(622): at android.content.res.Resources.getText(Resources.java:201)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.content.res.Resources.getString(Resources.java:254)
08-12 15:01:59.782: E/AndroidRuntime(622): at com.outsource.ecg.app.MainActivity$AppEntryAdapter.getView(MainActivity.java:138)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.ListView.onMeasure(ListView.java:1127)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.View.measure(View.java:8313)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.View.measure(View.java:8313)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.View.measure(View.java:8313)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.View.measure(View.java:8313)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.View.measure(View.java:8313)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.os.Looper.loop(Looper.java:123)
08-12 15:01:59.782: E/AndroidRuntime(622): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-12 15:01:59.782: E/AndroidRuntime(622): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:01:59.782: E/AndroidRuntime(622): at java.lang.reflect.Method.invoke(Method.java:507)
08-12 15:01:59.782: E/AndroidRuntime(622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-12 15:01:59.782: E/AndroidRuntime(622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-12 15:01:59.782: E/AndroidRuntime(622): at dalvik.system.NativeStart.main(Native Method)
08-12 15:02:02.223: I/Process(622): Sending signal. PID: 622 SIG: 9
我找到了解决方案。因为有两个STRING.XML文件(对于我不知道的一些神大坝原因)它们由IDE得到了混合。当我删除1时,它的工作原理 非常感谢每个人帮助我:)
答案 0 :(得分:0)
日志中的问题很明显:您正在尝试检索不可用的String资源。最有可能的是,你使用的是拼写错误的id。首先查看MainActivity.java:138
,然后查看您要获取的字符串ID。
同时检查布局XML - 可能您已为要加载的视图定义了一些文本,但该资源中的字符串不存在。
答案 1 :(得分:0)
试试这个,改变:
appButton.setText(mContext.getString(entry.displayNameResID()));
到
appButton.setText(mContext.getResources().getString(R.string.load_history_entry));