简体   繁体   English

如何修复在Android上启动时的应用崩溃

[英]How to fix App Crashes on launch on Android

I am still new to android app develop and right now i am stumble with this crashes and unable to fix 我仍然是Android应用程序开发的新手,现在我迷失了这个崩溃,无法修复

Manifest file Details 清单文件详细信息

<?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>

Can anyone PLEASE help me with this. 任何人都可以帮我这个忙。 it is so frustrated since i can not see where can go wrong. 它是如此沮丧,因为我看不到哪里会出问题。 the point of the app is to get the ecg signal to the app, draw it and store it ***edit : add appEntryAdapter 应用程序的要点是将ecg信号发送到应用程序,将其绘制并存储*** edit:添加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);
}

and this is line 137 and 138 in mainActivity 这是mainActivity中的137行和138行

final AppEntry entry = mAppEntries.get(arg0);
appButton.setText(mContext.getString(entry.displayNameResID()));

_ ------------------------------------------------------- R.string : _ ------------------------------------------------- ------ R.string:

   public static final class string {
        public static final int ID_label=0x7f040032;

public static final int about_app=0x7f040001; 公共静态最终int about_app = 0x7f040001;

String.xml 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>

---------------getview of appEntryAdapter --------------- 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));

appButton.setOnClickListener(new View.OnClickListener() { appButton.setOnClickListener(new View.OnClickListener(){

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

I FOUND A SOLUTION FOR THIS. 我为此找到了解决方案。 BECAUSE THERE WERE 2 STRING.XML FILE (FOR SOME GOD DAM REASON I DONT KNOW ABOUT) THEY GET MIXUP BY THE IDE. 因为存在2个STRING.XML文件(出于某些我不知道的原因),所以它们由IDE进行了混合。 WHEN I DELETE 1, IT WORKS THANKS EVERYONE SO MUCH FOR HELPING ME OUT :) 当我删除1时,它非常感谢所有人帮助我:)

The problem is clear from the log: you are trying to retrieve a String resource which isn't available. 从日志中可以清楚地看到问题:您正在尝试检索不可用的String资源。 Most probably, you're using a misspelled id. 最有可能的是,您使用的ID拼写错误。 Start by looking at MainActivity.java:138 and see what string ID you're trying to get. 首先查看MainActivity.java:138然后查看您要获取的字符串ID。

Also check the layout XML -- possibly you've defined some text for the view you're loading, but the string for that text does not exist in your resources. 还要检查布局XML-可能是您为正在加载的视图定义了一些文本,但是该文本的字符串在您的资源中不存在。

try this, change : 试试这个,改变:

appButton.setText(mContext.getString(entry.displayNameResID()));

to

appButton.setText(mContext.getResources().getString(R.string.load_history_entry));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM