我收到此警告:
所有com.android.support库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。找到了 版本27.1.1、27.1.0。例子包括 com.android.support:animated-vector-drawable:27.1.1和 com.android.support:exifinterface:27.1。
我理解这一点,但是即使所有com.android.support版本都相同,为什么还会向我显示此警告? (27.1.1)
这是我文件的内容:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.app.sin.retrolist"
minSdkVersion 18
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.71828' }
答案 0 :(得分:2)
要查看为什么在依赖项树中包含特定的依赖项,您可以(假设您的主模块名为(env) Cam@cambook:~/Sites/juke% python manage.py makemigrations playlists
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/Cam/Sites/juke/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/Cam/Sites/juke/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/Users/Cam/Sites/juke/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/Cam/Sites/juke/env/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/Users/Cam/Sites/juke/env/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/Cam/Sites/juke/playlists/models.py", line 60, in <module>
class Track(models.Model):
File "/Users/Cam/Sites/juke/playlists/models.py", line 63, in Track
number = PositiveSmallIntegerField()
NameError: name 'PositiveSmallIntegerField' is not defined
并且您在macOS上)运行简单:
app
在控制台输出中,您将看到完整的依赖树以及如何解析库版本。
处理依赖项冲突的正确方法是明确定义解决策略:
./gradlew app:dependencies
此文件必须放在configurations.all {
resolutionStrategy {
force 'com.android.support:exifinterface:27.1.1'
}
}
模块中build.gradle
文件的根目录中。
使用以下方法覆盖冲突的依赖项:
app
不太正确,因为您的模块不直接 依赖于此库,因此,例如,如果以后版本的依赖项不再依赖于此库,它仍将包含在已解决的依赖项列表,即使您不需要它也是如此。
更好的是,您可以定义:
dependencies {
...
implementation 'com.android.support:exifinterface:27.1.1'
}
在主ext {
supportLibVersion = "27.1.1"
}
文件中,然后在需要的地方使用它:
build.gradle