【问题标题】:Android emulator craches when Using SmsManager to send SMS使用 SmsManager 发送短信时 Android 模拟器崩溃
【发布时间】:2015-04-29 23:41:39
【问题描述】:

我点击我的应用程序中的发送按钮,模拟器出现以下错误消息:

HAX 正在工作,模拟器以快速 virt 模式运行
dyld:惰性符号绑定失败:找不到符号:_utf8_write 引用自:/Users/Nabil/Documents/Development/Android/sdk/tools/emulator64-x86 预期在:平面命名空间 dyld:找不到符号:_utf8_write 引用自:/Users/Nabil/Documents/Development/Android/sdk/tools/emulator64-x86 预期在:平面命名空间

这是我的课程代码:

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();
        }
    }

和我的清单文件:

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

【问题讨论】:

  • 您的代码和清单看起来正确。模拟器在什么机器上运行?
  • 尝试在真机上运行你的应用。
  • 迈克,我正在使用 nexus one
  • @NabilElAtlas 实际上,我指的是您的计算机。至少在 Mac 上似乎是 bug in the emulator
  • 我有一个 mac os yosemite 10.10.1

标签: android android-emulator


【解决方案1】:

首先知道安卓模拟器不是真正的设备。使用任何真实设备,因为真实设备仅与硬件配置(Sim Card)交互。

【讨论】:

  • 不需要添加 sim 来检查模拟器中的消息应用程序,我们可以这样做
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-09
  • 2014-01-09
相关资源
最近更新 更多