简体   繁体   English

使用SmsManager发送短信时Android模拟器崩溃

[英]Android emulator craches when Using SmsManager to send SMS

I click on send button in my app and emulator craches with following error message : 我在我的应用程序中单击“发送”按钮,并且仿真器出现以下错误消息:

HAX is working and emulator runs in fast virt mode HAX正在运行并且仿真器以快速virt模式运行
dyld: lazy symbol binding failed: Symbol not found: _utf8_write Referenced from: /Users/Nabil/Documents/Development/Android/sdk/tools/emulator64-x86 Expected in: flat namespace dyld: Symbol not found: _utf8_write Referenced from: /Users/Nabil/Documents/Development/Android/sdk/tools/emulator64-x86 Expected in: flat namespace dyld:懒惰的符号绑定失败:找不到符号:_utf8_write引用自:/ Users / Nabil / Documents / Development / Android / sdk / tools / emulator64-x86预期使用:平面命名空间dyld:找不到符号:_utf8_write引用自:/ Users / Nabil / Documents / Development / Android / sdk / tools / emulator64-x86预期用于:平面名称空间

Here is my class code : 这是我的课程代码:

public void Send (View view){
        txtnum = (EditText)findViewById(R.id.txtNum);
        txtmsg = (EditText)findViewById(R.id.txtMessage);
        String phoneNo = txtnum.getText().toString();
        String message = txtmsg.getText().toString();

        try {

            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(phoneNo, null, message, null, null);
            Toast.makeText(getApplicationContext(), "SMS sent.",
                    Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(),
                    "SMS faild, please try again.",
                    Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }

and my manifest file: 和我的清单文件:

<uses-permission android:name="android.permission.SEND_SMS" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".MainActivity"
            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>

First know android simulators are not real devices. 首先知道android模拟器不是真正的设备。 Use any real devices, because real devices only interact with hardware config(Sim Card). 使用任何真实设备,因为真实设备仅与硬件配置(Sim卡)交互。

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

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