首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle不会生成输出APK

Gradle不会生成输出APK
EN

Stack Overflow用户
提问于 2015-03-12 02:48:39
回答 2查看 10.3K关注 0票数 4

我正试图在命令行上为我的android项目生成一个APK。我在跑步

代码语言:javascript
复制
./gradlew clean assembleProductionDebug

我得到的输出是:

代码语言:javascript
复制
:app:processProductionDebugManifest
:app:processProductionDebugResources
:app:generateProductionDebugSources
:app:compileProductionDebugJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:preDexProductionDebug
:app:dexProductionDebug
:app:processProductionDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageProductionDebug
:app:zipalignProductionDebug
:app:assembleProductionDebug

BUILD SUCCESSFUL

Total time: 2 mins 29.574 secs

但是,我的build/output文件夹是空的。当我运行./gradlew assemble时也会发生同样的情况

我可以搜索的唯一相关内容是潜在的https://gradle.org/docs/current/dsl/org.gradle.language.assembler.tasks.Assemble.html,但是如何在build.gradle中指定objectFileDir呢?

注意:运行

代码语言:javascript
复制
./gradlew clean installProductionDebug

确实在我的设备上成功安装了APK。

相关build.gradle:

代码语言:javascript
复制
apply plugin: 'com.android.application'
apply plugin: 'git-dependencies'
apply plugin: 'testfairy'
apply plugin: 'org.robolectric'


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.test.androidas"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        release {
             storeFile file("as.keystore")
             storePassword "***"
             keyAlias "as"
             keyPassword "***"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }


    productFlavors {
        production {
            applicationId "com.antsquare.test"
            versionCode 1
        }

        staging {
            applicationId "com.antsquare.test.staging"
            versionCode 1
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    testfairyConfig {
        apiKey '***'
        video "wifi"
        notify true
        testersGroups "ME"
        autoUpdate true
        videoQuality "low"
        videoRate "0.5"
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-12 03:10:04

第一次添加

代码语言:javascript
复制
android { 

     compileSdkVersion 21
     buildToolsVersion "21.1.2"

     ...

     lintOptions { 
         abortOnError false 
     } 
}

app模块中的build.gradle中。

之后,通过./gradlew task clean清理你的项目,然后从控制台调用./gradlew task build --debug | grep .apk,你会看到apk的位置

票数 3
EN

Stack Overflow用户

发布于 2017-07-16 22:09:27

在Android Studio中,

如果构建成功但未生成

.apk

文件,而不是启动模拟器。

Solution:确保将menu中的build下方的下拉菜单或run左侧的下拉列表选择为'app‘,然后当您运行debug时,

.apk

文件将会生成,模拟器将会启动。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28994942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档