leanflutter / flutter_distributor

An all-in-one Flutter application packaging and distribution tool, providing you with a one-stop solution to meet various distribution needs.
https://distributor.leanflutter.dev/
MIT License
884 stars 122 forks source link

执行 AppPackageMakerApk 时报outputFiles为空 #128

Closed hfbi360 closed 1 year ago

hfbi360 commented 1 year ago

flutter-distributor版本0.3.1 ,flutter版本3.7.10 输出信息: { "config": { "mode": "release", "flavor": "huong", "arguments": { "target": "lib/main.dart", "flavor": "huong", "target-platform": "android-arm,android-arm64", "dart-define": { "APP_ENV": "product" } } }, "outputDirectory": "build/app/outputs/apk/huong/release", "duration": 359866, "outputFiles": [] } Successfully built Directory: 'build/app/outputs/apk/huong/release' in 359s Bad state: No element

0 List.first (dart:core-patch/growable_array.dart:343:5)

1 AppPackageMakerApk.make (package:flutter_app_packager/src/makers/apk/app_package_maker_apk.dart:13:29)

2 FlutterAppPackager.package (package:flutter_app_packager/src/flutter_app_packager.dart:40:18)

3 FlutterDistributor.package (package:flutter_distributor/src/flutter_distributor.dart:181:51)

#4 FlutterDistributor.release (package:flutter_distributor/src/flutter_distributor.dart:320:45) #5 CommandRunner.runCommand (package:args/command_runner.dart:209:13) 请问是哪里配置错误吗?旧版本0.2.4正常打包,升级上来后报这个错。
lijy91 commented 1 year ago

可以提供一下你的 build.gradle 的配置吗?

hfbi360 commented 1 year ago

可以提供一下你的 build.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 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.0' }

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android { compileSdkVersion rootProject.ext.android["compileSdkVersion"]

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

defaultConfig {
    applicationId rootProject.ext.app["applicationId"]
    minSdkVersion rootProject.ext.android["minSdkVersion"]
    targetSdkVersion rootProject.ext.android["targetSdkVersion"]
    versionCode rootProject.ext.app["versionCode"]
    versionName rootProject.ext.app["versionName"]
    manifestPlaceholders = [TENCENT_APP_ID: "appId"]
    multiDexEnabled true
    ndk{
        abiFilters "armeabi-v7a","arm64-v8a"
    }

    configurations.all {
        resolutionStrategy {
            force 'androidx.core:core:1.6.0'
            force 'androidx.core:core-ktx:1.6.0'
        }
    }

}

signingConfigs {
    debug {
        storeFile file(project.hasProperty('RELEASE_STORE_FILE') ? RELEASE_STORE_FILE : System.getenv('RELEASE_STORE_FILE'))
        storePassword project.hasProperty('RELEASE_STORE_PASSWORD') ? RELEASE_STORE_PASSWORD : System.getenv('RELEASE_STORE_PASSWORD')
        keyAlias project.hasProperty('RELEASE_KEY_ALIAS') ? RELEASE_KEY_ALIAS : System.getenv("RELEASE_KEY_ALIAS")
        keyPassword project.hasProperty('RELEASE_KEY_PASSWORD') ? RELEASE_KEY_PASSWORD : System.getenv("RELEASE_KEY_PASSWORD")
        // No debug config

    }

    release {
        storeFile file(RELEASE_STORE_FILE)
        storePassword RELEASE_STORE_PASSWORD
        keyAlias RELEASE_KEY_ALIAS
        keyPassword RELEASE_KEY_PASSWORD

    }
}

buildTypes {
    debug {
        minifyEnabled false
        zipAlignEnabled false
        // 移除无用的resource文件
        shrinkResources false
        signingConfig signingConfigs.debug
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        ndk {
            abiFilters "armeabi", "armeabi-v7a","arm64-v8a"
        }
    }

    profile {
        minifyEnabled false
        zipAlignEnabled false
        // 移除无用的resource文件
        shrinkResources false
        signingConfig signingConfigs.debug
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        ndk {
            abiFilters "armeabi", "armeabi-v7a","arm64-v8a"
        }
    }

    release {
        minifyEnabled true
        zipAlignEnabled true
        // 移除无用的resource文件
        shrinkResources true
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        ndk{
            abiFilters "armeabi-v7a","arm64-v8a"
        }
    }
}

lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false

}

flavorDimensions "mode"

productFlavors {
    huiwei {}
}

// 自定义APK安装包名
applicationVariants.all { variant ->
    variant.outputs.all { output ->
        def outputFile = output.outputFile
        if (outputFile != null && outputFile.name.endsWith('.apk')) {
            def fileName = "student_v${defaultConfig.versionName}_${buildTime()}.apk"
            outputFileName = fileName
        }
    }
}

buildFeatures {
    dataBinding = true
}

}

def buildTime() { return new Date().format("yyyy-MM-dd HH:MM:ss" , TimeZone.getTimeZone("UTC")) }

flutter { source '../..' }

dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.multidex:multidex:2.0.1' implementation ('com.github.bumptech.glide:glide:4.11.0') { exclude group: "com.android.support" } kapt 'com.github.bumptech.glide:compiler:4.11.0' }

lijy91 commented 1 year ago

@hfbi360 看起来是因为 build.gradle 中增加了自定义APK安装包名的配置,导致输出目录不是默认目录导致,请移除这部分配置后重试

lijy91 commented 1 year ago

请更新到 0.3.3 后重试

hfbi360 commented 1 year ago

请更新到 0.3.3 后重试

多谢