在构建和运行 Flutter 项目时遇到问题

时间:2021-06-03 11:51:03

标签: android firebase flutter gradle release

我已经创建了我的应用程序的发布版本。但我无法运行它。我遇到了不同的问题,但我无法解决。我尝试了多种方法,但我无法理解出了什么问题。

在调试版本中运行良好的项目在发布版本中不起作用。 就像谷歌登录一样。它在调试模式下工作,但不在发布模式下。以下是我无法解决的一些问题。任何帮助将不胜感激。谢谢。

  1. values/styles.xml 我收到如下错误:“无法解析符号:android:windowBackground”。当我搜索相同的财产时,对其他人有用,但对我却不起作用。 Error for theme in styles.xml

  2. 向注册商发出警告。 plugin registry error

  3. flutter 构建异常 exception for flutter build

  4. 当我收到构建异常时,我无法安装它。 enter image description here

  5. 清单文件有问题: manifest issues

以下是android manifest中的问题列表 enter image description here 下面是我的 gradle 文件代码:

app/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 FileNotFoundException("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: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
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

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.myproject.artsvalley"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.material:material:1.1.0'
}

项目级别:build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'


task clean(type: Delete) {
    delete rootProject.buildDir
}

0 个答案:

没有答案