【问题标题】:migrating to flutter to androidX fails迁移到颤振到 androidX 失败
【发布时间】:2020-02-28 20:15:33
【问题描述】:

当我尝试将我的颤振项目迁移到 Androidx 时,它给了我以下错误。 您需要在模块 build.grandle 中将 compileSdk 设置为至少 28 才能迁移到 Androidx

我尝试将 targetSdk 版本更改为 28,但没有解决。

build.grandle 中的代码 - android

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

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
}

build.grandle 中的代码 - 应用程序

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.sayuru.clima"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.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 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

grandle.property 中的代码

android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536M

【问题讨论】:

  • 添加系统日志

标签: flutter androidx


【解决方案1】:

我解决了这个问题:

  1. 右键android目录->flutter->在Android Studio中打开Android模块
  2. 从项目结构更新 gradle
  3. 通过 sdk manager 工具安装 google play 服务。
  4. 然后重构 -> 迁移到 androidx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-25
    • 2020-06-06
    • 1970-01-01
    • 1970-01-01
    • 2020-02-03
    • 1970-01-01
    • 2019-11-12
    相关资源
    最近更新 更多