依存関係にAndroidのサポートライブラリの複数のバージョンを解決する質問に表示されます。

アプリではbuild.gradle、我々は、導入された次の依存エラーが見つかりました:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:support-media-compat:26.1.0 less... (⌘F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

簡単に言えば、Androidのサポートライブラリの2つのバージョン、それにどのようにこのような状況の契約の導入でありますか?

  1. 統一された管理サポートパッケージのバージョン番号。
  2. サードパーティのサポートライブラリに含まれているパッケージ、およびサポートパッケージの一貫性のあるバージョンの導入を除きます。

次のように:


ext.versions = [
  play_services: '15.0.1',
  // 统一管理支持包的版本号
  suport_library: '27.1.1',
]

dependencies {
  implementation("com.google.android.gms:play-services-gcm:${versions.play_services}") {
    // 剔除 play service 中包含的 v4 支持包
    exclude group: 'com.android.support', module: 'support-v4'
  }
  // 引入版本一致的 v4 支持包
  implementation "com.android.support:support-v4:${versions.suport_library}"
  implementation "com.android.support:appcompat-v7:${versions.suport_library}"
  implementation "com.android.support:recyclerview-v7:${versions.suport_library}"
  implementation "com.android.support:cardview-v7:${versions.suport_library}"
  implementation "com.android.support:support-annotations:${versions.suport_library}"
}

通常の場合には、我々は依存の数を導入している、私たちが繰り返し紹介サポートライブラリの導入に依存しているかわからない、私たちはそれを分析するのに役立つツールはありませんか?

答えはつまり、はい、Gradleのコマンドが実行できる持っているgradle dependencies、それが依存しており、依存性が出て設定依存することができます。Androidのメーカーはまた、ツールバーの右側にすることができGradle --> help--> dependencies、分析は、依存関係を開始します。以下のように依存し、例えば、実行:

+--- com.google.android.gms:play-services-gcm:15.0.1
|    +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 15.0.1
|    |    +--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1
|    |    |    \--- com.android.support:support-v4:26.1.0 -> 27.1.1
|    |    |         +--- com.android.support:support-compat:27.1.1
|    |    |         |    +--- com.android.support:support-annotations:27.1.1
|    |    |         |    \--- android.arch.lifecycle:runtime:1.1.0
|    |    |         |         +--- android.arch.lifecycle:common:1.1.0
|    |    |         |         \--- android.arch.core:common:1.1.0
|    |    |         +--- com.android.support:support-media-compat:27.1.1
|    |    |         |    +--- com.android.support:support-annotations:27.1.1
|    |    |         |    \--- com.android.support:support-compat:27.1.1 (*)
|    |    |         +--- com.android.support:support-core-utils:27.1.1
|    |    |         |    +--- com.android.support:support-annotations:27.1.1
|    |    |         |    \--- com.android.support:support-compat:27.1.1 (*)
|    |    |         +--- com.android.support:support-core-ui:27.1.1
|    |    |         |    +--- com.android.support:support-annotations:27.1.1
|    |    |         |    +--- com.android.support:support-compat:27.1.1 (*)
|    |    |         |    \--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |         \--- com.android.support:support-fragment:27.1.1
|    |    |              +--- com.android.support:support-compat:27.1.1 (*)
|    |    |              +--- com.android.support:support-core-ui:27.1.1 (*)
|    |    |              +--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |              +--- com.android.support:support-annotations:27.1.1
|    |    |              +--- android.arch.lifecycle:livedata-core:1.1.0
|    |    |              |    +--- android.arch.lifecycle:common:1.1.0
|    |    |              |    +--- android.arch.core:common:1.1.0
|    |    |              |    \--- android.arch.core:runtime:1.1.0
|    |    |              |         \--- android.arch.core:common:1.1.0
|    |    |              \--- android.arch.lifecycle:viewmodel:1.1.0
|    |    \--- com.google.android.gms:play-services-tasks:[15.0.1] -> 15.0.1
|    |         \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    +--- com.google.android.gms:play-services-iid:[15.0.1] -> 15.0.1
|    |    +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-stats:[15.0.1,16.0.0) -> 15.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    |    \--- com.google.android.gms:play-services-tasks:[15.0.1,16.0.0) -> 15.0.1 (*)
|    \--- com.google.android.gms:play-services-stats:[15.0.1,16.0.0) -> 15.0.1 (*)
+--- com.android.support:support-v4:27.1.1 (*)
+--- com.android.support:appcompat-v7:27.1.1
|    +--- com.android.support:support-annotations:27.1.1
|    +--- com.android.support:support-core-utils:27.1.1 (*)
|    +--- com.android.support:support-fragment:27.1.1 (*)
|    +--- com.android.support:support-vector-drawable:27.1.1
|    |    +--- com.android.support:support-annotations:27.1.1
|    |    \--- com.android.support:support-compat:27.1.1 (*)
|    \--- com.android.support:animated-vector-drawable:27.1.1
|         +--- com.android.support:support-vector-drawable:27.1.1 (*)
|         \--- com.android.support:support-core-ui:27.1.1 (*)
+--- com.android.support:recyclerview-v7:27.1.1
|    +--- com.android.support:support-annotations:27.1.1
|    +--- com.android.support:support-compat:27.1.1 (*)
|    \--- com.android.support:support-core-ui:27.1.1 (*)
+--- com.android.support:cardview-v7:27.1.1
|    \--- com.android.support:support-annotations:27

おすすめ

転載: www.cnblogs.com/lshare/p/11333978.html