【发布时间】:2019-12-25 04:55:41
【问题描述】:
我尝试从我的颤振应用程序生成 apk。但是每次我都变成这个错误码
FAILURE:构建失败并出现异常。
出了什么问题:无法确定任务的依赖关系 ':应用程序:lintVitalRelease'。无法解析所有工件 配置':app:debugAndroidTestCompileClasspath'。 找不到 androidx.test:runner:1.2.1。 要求: 项目:应用程序 找不到 androidx.test.espresso:espresso-core:3.2.1。 要求: 项目:应用程序
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。运行 --info 或 --debug 选项以获得更多日志输出。运行 --scan 以获得完整的见解。
通过https://help.gradle.org获得更多帮助
这是 /app 中的 build.gradle 文件
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
这是 /app/src/ 中的 build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '0.0.1'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.***.***"
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.1'
}
apply plugin: 'com.google.gms.google-services'
我在 github 或 stackoverflow 上一无所获。有人有想法吗?
【问题讨论】:
-
请在您的问题中添加您的两个 build.gradle 文件
-
我注释掉这两行 //androidTestImplementation 'androidx.test:runner:1.2.1' //androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.1' 我可以生成现在发布 apk,但我认为这不是解决方案
-
尝试将两个类路径都更改为类路径 'com.android.tools.build:gradle:3.5.0' 类路径 'com.google.gms:google-services:4.3.0' 让我知道它是否有效
-
对不起,它没有任何改变。错误又来了。
-
我找到了另一个解决方案。另一种方法是更改测试实现的版本。 androidx.test:runner:1.2.1 到 1.1.1 和 espress 3.2.1 到 3.1.1。这也解决了。但我不确定这是否很好。