TaillookTech

モバイルアプリ開発を追っています

Androidでcom.android.support:support-v4のバージョンが衝突した話

問題

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

2つのバージョンのclasspathがあるため衝突が起き,ビルド出来ない.

解決

build.gradleのsubprojectsに

project.configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support') {
            details.useVersion "26.1.0" or "27.1.1"
        }
    }
}

を追記するとバージョンを指定できる.