android studio flutter app打包

首先在 terminal 生成签名文件

keytool -genkey -v -keystore D:/app/android/haitao_key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias keyalias

D:/app/android/haitao_key.jks  文件的保存路径,keyalias 签名文件别名。根据操作提示处理

然后新建文件 key.properties

然后修改 app目录下的 build.gradle

在Android之前添加

def keyPropertiesFile=rootProject.file("key.properties")
def keyProperties=new Properties()
keyProperties.load(new FileInputStream(keyPropertiesFile))

然后修改

signingConfigs{
    release{
        keyAlias keyProperties['keyAlias']
        keyPassword keyProperties['keyPassword']
        storeFile file(keyProperties['storeFile'])
        storePassword keyProperties['storePassword']
    }
    debug{
        keyAlias keyProperties['keyAlias']
        keyPassword keyProperties['keyPassword']
        storeFile file(keyProperties['storeFile'])
        storePassword keyProperties['storePassword']
    }
}

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.release
    }
}

最后再 terminal 执行 flutter build apk 生成打包app

猜你喜欢

转载自blog.csdn.net/weixin_41191134/article/details/88837684