在应用模块中更改build.gradle后,出现错误:找不到符号方法setVolumeControlStream

时间:2018-06-28 05:14:06

标签: android

我的新build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "com.example.koran.myapplication"
    minSdkVersion 16
    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'
    }
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/animations'] } }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-games:15.0.1'
}

我将compileSdkVersion从26(与targetSdkVersion相同)更改为27。

唯一的编译错误是error: cannot find symbol method setVolumeControlStream(int)。从我的onStart()的{​​{1}}方法(扩展了MainActivity)中调用此方法。更改gradle文件后,我才开始出现此错误。我很确定这是因为这一行:

AppCompatActivity

我从这一行得到一个错误

implementation 'com.android.support:appcompat-v7:27.0.0'

这是什么意思?为什么All com.android.support libraries must use the exact same version specification无法识别?

0 个答案:

没有答案