当我./gradlew assembleRelease
我的React原生应用程序,我得到:
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestRuntimeClasspath'.
> Could not find com.android.support:multidex-instrumentation:27.1.1.
什么需要改变才能做到正确?
我的build.gradle:
android {
defaultConfig {
// ...
multiDexEnabled true // if I comment it, I run into the multidex needed error : The number of method references in a .dex file cannot exceed 64K.
}
}
dependencies {
// ...
implementation 'com.android.support:multidex:1.0.3' // commenting it does not change the problem
}
如果您使用react-native-navigation
,那么您的app / build.gradle中会出现类似的情况:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
确保排除在上述条件下给您带来问题的库。像这样:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support'
&& requested.name != 'multidex'
&& requested.name != 'multidex-instrumentation') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}