简体   繁体   English

为什么我的APK文件显示app-debug.apk? 如何重命名?

[英]Why does my APK file say app-debug.apk? How do I rename it?

Whenever I try to export my code file it always exports as app-debug.apk. 每当我尝试导出代码文件时,它始终会导出为app-debug.apk。 Is there any way to change its name without messing up my code? 有什么办法可以在不弄乱我的代码的情况下更改其名称? The reason I am asking is because I recently changed my app name in the wrong spot and the whole program stopped working. 我问的原因是因为我最近在错误的位置更改了应用名称,并且整个程序停止工作。

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

def buildType = ""

android {

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.deep.practicle"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            buildType = "release"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug{
            buildType = "debug"
        }

    }
    dataBinding {
        enabled = true
    }

}

android.applicationVariants.all { variant ->

    variant.outputs.all {
        def appName = buildType
        outputFileName = appName + "-${variant.versionName}.apk"
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    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'

    // Support
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'

}

Hi Bro, just variable create in build.gradle. 嗨,兄弟,只是在build.gradle中创建变量。

That is because your module name is app and build type is debug. 那是因为您的模块名称是app,构建类型是debug。 To change the outputFileName place below code in android {} section of your app build.gradle file (it is the format I use for my apps, you can name the way you want taking this as reference) 要在您的应用程序build.gradle文件的android {}部分中的代码下面更改outputFileName位置(这是我用于我的应用程序的格式,您可以命名此方式作为参考)

android.applicationVariants.all { variant ->
        variant.outputs.all {
            def appName = "YourAppName"
            def date = new Date()
            def formattedDate = date.format('MMM-dd-yyyy')
            outputFileName = appName + formattedDate + "-${variant.versionName}-${variant.versionCode}.apk"
        }
    }

On the left side of Android Studio, choose Build Variants. 在Android Studio的左侧,选择Build Variants。 This is 3rd tab from bottom. 这是底部的第3个标签。 Select "release" instead of "debug". 选择“发布”而不是“调试”。 Your release APK will be placed in the release folder. 您的发布APK将放置在发布文件夹中。 It will not be appended with a "debug". 它不会附加“调试”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM