短信管理员给我这个错误

时间:2016-09-05 12:17:05

标签: android

我正在尝试从Android应用程序发送短信到SIM号码。短信经理给我这个错误。

  

错误:任务':app:transformClassesWithInstantRunForDebug'的执行失败。    android / telephony / SmsManager:不支持的major.minor版本52.0

这是我的代码

 private class MyCLiCkListner implements View.OnClickListener {
        @Override
        public void onClick(View view) {


            String number = "03470000000";
            String sms = "hi Mehdi";

            try {
                SmsManager smsManager = SmsManager.getDefault();
                smsManager.sendTextMessage(number, null, sms, null, null);
                Toast.makeText(getApplicationContext(), "SMS Sent!",
                        Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(),
                        "SMS faild, please try again later!",
                        Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }
        }
    }

这是我的傻瓜

android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "balti.sendsmsonnumber"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'``
}

1 个答案:

答案 0 :(得分:0)

尝试禁用即时运行,如下图所示  enter image description here