在AVD上测试ITelephony endCall会抛出java.lang.NoSuchMethodError

问题描述 投票:0回答:1

[当操作系统为棉花糖或更高版本时,我没有执行呼叫阻止代码的问题,但在AVD的Kitkat上对其进行了测试会抛出java.lang.NoSuchMethodError: com.android.internal.telephony.ITelephony.endCall

public interface ITelephony {

     void endCall();
     void silenceRinger();

}

这些是所使用的权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />

这正在BroadcastReceiver中执行:

Class<?> c = Class.forName(tm.getClass().getName());

Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);      

ITelephony telephonyService = (ITelephony) m.invoke(tm);

telephonyService.silenceRinger();
telephonyService.endCall();

这是我的礼物:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.app.testapp"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.8.3'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
}
android avd
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.