簡體   English   中英

Flutter:嘗試遷移到Android X后在Android中構建問題

[英]Flutter: Problem to build in Android after trying to migrate to Android X

在嘗試將項目遷移到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)

我的構建文件:app / 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM