我在尝试构建 apk 时遇到构建 gradle 错误
i have a build gradle error when trying to build an apk
我在尝试构建和 apk 时遇到此错误:
失败:构建失败,出现异常。
- 出了什么问题:
无法确定任务“:app:lintVitalRelease”的依赖项。
Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'.
Could not find com.google.firebase:firebase-analytics:.
Required by:
project :app
尝试:
运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。 运行 使用 --scan 以获得完整的见解。
- 获取更多帮助
我在 运行 构建 apk 时没有任何问题。由于现在已经解决的另一个问题,我已经更改了 min sdk 文件,但我认为这不会影响项目。它告诉我代码太多,所以我必须以某种方式填写它,即使很难,也没有什么可说的。非常感谢那些帮助过你的人
这是代码:
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 = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.untitled2"
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
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.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.android.support:multidex:1.0.3'
我找到了我必须 运行 pub get firebase-analytics 的解决方案,它奏效了。
我在尝试构建和 apk 时遇到此错误: 失败:构建失败,出现异常。
- 出了什么问题: 无法确定任务“:app:lintVitalRelease”的依赖项。
Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'. Could not find com.google.firebase:firebase-analytics:. Required by: project :app
尝试: 运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。 运行 使用 --scan 以获得完整的见解。
- 获取更多帮助
我在 运行 构建 apk 时没有任何问题。由于现在已经解决的另一个问题,我已经更改了 min sdk 文件,但我认为这不会影响项目。它告诉我代码太多,所以我必须以某种方式填写它,即使很难,也没有什么可说的。非常感谢那些帮助过你的人 这是代码:
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 = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.untitled2"
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
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.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.android.support:multidex:1.0.3'
我找到了我必须 运行 pub get firebase-analytics 的解决方案,它奏效了。