在签署Flutter应用程序时,我无法构建该应用程序*已编辑*

时间:2019-11-25 18:57:30

标签: android gradle flutter signing

所以我想将Flutter应用发布到Play商店。我签署了该应用程序,但此后该应用程序将无法构建。当我尝试通过appbundle构建我的应用程序时,它将返回以下内容:

C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\tab>flutter build appbundle
Initializing gradle...                                              1,1s
Resolving dependencies...                                           5,6s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done                        11,9s
Gradle task bundleRelease failed with exit code 1

当我尝试通过胖APK构建应用程序时,出现了更长的错误,但仍然是一个谜:¨

C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\tab>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle...                                              1,4s
Resolving dependencies...                                          23,0s
Note: C:\Users\tbsvst18tedbom\Desktop\Appen\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+9\android\src\main\java\io\flutter\plugins\firebaseadmob\AdRequestBuil
derFactory.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\tbsvst18tedbom\Desktop\Appen\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-5.2.5\android\src\main\java\io\flutter\plugins\urllauncher\WebViewActivity.jav
a uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Running Gradle task 'assembleRelease'...

Running Gradle task 'assembleRelease'... Done                     133,5s (!)
Gradle task assembleRelease failed with exit code 1

如果有帮助,我将添加应用程序级别的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 new 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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    signingConfigs {
        release {
            storeFile file('C:\\Users\\tbsvst18tedbom\\Desktop\\Appen\\KeyStore\\TABKEY.jks')
            storePassword '***'
            keyAlias = 'TABTRUTH1'
            keyPassword '***'
        }
    }
    compileSdkVersion 29

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.tab.tab"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode = flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.release
    }

    buildTypes {
        release {
            multiDexEnabled true
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro'
        }
    }
}

    flutter {
        source '../..'
    }

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.60"
        testImplementation 'junit:junit:4.13-rc-1'
        androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
        implementation 'com.google.firebase:firebase-ads:18.3.0'
        implementation 'com.google.firebase:firebase-appindexing:19.0.0'
        implementation 'com.google.android.gms:play-services-ads:18.3.0'
    }

apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

我希望任何人都可以通过这个奇怪的错误消息来帮助我。我不知道问题出在什么地方,因为在我签署该应用程序之前,它运行良好。

如果您需要任何文件,只需说出这个词,然后我将编辑问题。

非常感谢您!

EDIT1 根据要求,这是pubspec.yaml文件

name: tab
description: TAB2

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  url_launcher: ^5.0.0
  firebase_admob: ^0.9.0+9
  firebase_core: ^0.4.2
  firebase_analytics: ^5.0.6


dev_dependencies:
  flutter_launcher_icons: "^0.7.3"

  flutter_test:
    sdk: flutter

flutter_launcher_icons: "^0.7.3"

flutter_icons:
  android: true
  ios: true
  image_path: "Images/Logo_utan_text.png"

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - Images/logotype.png
    - Images/Logo_utan_text.png

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

经过进一步调查,我找到了它创建的构建。该文件夹包含所有信息,但没有APK。我相信apk无法签名,因此无法创建吗?如果我错了,请纠正我。

谢谢!

EDIT3 当我运行gradle sync时,出现了gradle问题

INFO: 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 more information.
Affected Modules: app

有人知道该怎么做吗?

3 个答案:

答案 0 :(得分:1)

Flutter在How to Set Your JMeter Load Test to Use Client Side Certificates上做了一个对我有用的指南。您应该尝试一下。

答案 1 :(得分:1)

选项1:

  

Kotlin编译器设置。

您可以在此处找到该设置:文件->设置-> Kotlin编译器-> 目标JVM版本

选项2:

  

更新Kotlin插件

我可能是您的IDE具有较旧级别的Kotlin插件。

在Android Studio中,进入File > Settings... > Kotlin并检查以确保您的插件是最新的。您可能会看到类似这样的信息,表明您需要更新:

enter image description here

此外,如果遇到内存问题,可能需要将org.gradle.jvmargs=-Xms1024m -Xmx4096m添加到gradle.properties文件中。

答案 2 :(得分:0)

好像我给keyAlias命名错误一样,现在我更改了它就可以了。非常感谢您的所有帮助。