gpt4 book ai didi

android - Flutter:尝试迁移到 Android X 后在 Android 中构建的问题

转载 作者:IT王子 更新时间:2023-10-29 06:38:05 24 4
gpt4 key购买 nike

在尝试将我的项目迁移到 AndroidX 后,我遇到了很多问题,但仍然无法成功构建。

现在,当我尝试构建时,出现以下错误:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
* Error running Gradle:
ProcessException: Process "/Users/felipe/MYAPPANAME/android/gradlew" exited abnormally:

> Configure project :app
WARNING: minSdkVersion (21) is greater than targetSdkVersion (18) for variant "debug". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (21) is greater than targetSdkVersion (18) for variant "dynamicProfile". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (21) is greater than targetSdkVersion (18) for variant "release". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (21) is greater than targetSdkVersion (18) for variant "profile". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
WARNING: minSdkVersion (21) is greater than targetSdkVersion (18) for variant "dynamicRelease". Please change the values such that minSdkVersion is less than or equal to targetSdkVersion.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

> Configure project :camera

Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':camera'.
> Could not resolve all artifacts for configuration ':camera:classpath'.
> Could not find com.com.MYAPPNAME.android.tools.build:gradle:3.3.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/com/MYAPPNAME/android/tools/build/gradle/3.3.0/gradle-3.3.0.pom
- https://dl.google.com/dl/android/maven2/com/com/MYAPPNAME/android/tools/build/gradle/3.3.0/gradle-3.3.0.jar
- https://jcenter.bintray.com/com/com/MYAPPNAME/android/tools/build/gradle/3.3.0/gradle-3.3.0.pom
- https://jcenter.bintray.com/com/com/MYAPPNAME/android/tools/build/gradle/3.3.0/gradle-3.3.0.jar
Required by:
project :camera

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
Command: /Users/felipe/MYAPPNAME/android/gradlew app:properties

Please review your Gradle project setup in the android/ folder.
Exited (sigterm)

我的构建文件:应用程序/build.gladle:

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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.MYAPPNAME.android"
minSdkVersion 21
targetSdkVersion 18
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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 {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}

apply plugin: 'com.google.gms.google-services'

build.gradle:

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0' //firebase
}
}

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
}

我不知道我还能做什么,我看了很多关于配置文件的问题,但我还没有找到答案。

最佳答案

targetSdkVersion 18

应该是

targetSdkVersion 28

另见 https://developer.android.com/distribute/best-practices/develop/target-sdk

关于android - Flutter:尝试迁移到 Android X 后在 Android 中构建的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55100057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com