Gradle does not generate an output APK
Asked Answered
K

2

6

I'm trying to generate an APK for my android project on the command line. I am running

./gradlew clean assembleProductionDebug

The output I get is:

: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

However, my build/outputs folder is empty. The same happens when I run ./gradlew assemble

The only relevant thing I could search for is potentially https://gradle.org/docs/current/dsl/org.gradle.language.assembler.tasks.Assemble.html but how do I specify the objectFileDir in the build.gradle?

Note: running

./gradlew clean installProductionDebug

does successfully install the APK on my device.

Relevant build.gradle:

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"
    }
}
Kumar answered 11/3, 2015 at 18:48 Comment(11)
Where do you try to find for this file? This file is not visible in Android StudioPhilippine
It is {project}/app{or folder of your module}/build/outputs/apk/*.apkPhilippine
By file do you mean the APK? I am looking for it in /<app>/build/outputs/apk/Kumar
yes there should be there if not clean your project and run ./gradlew buildPhilippine
In <app>/build/ I do not have an outputs folder, only an intermediates folder. I manually created outputs/apk/ but it is still not put thereKumar
Use some file explorer not android studioPhilippine
Yes, I am using ls -A build/outputs/apk . it is emptyKumar
Did you call ./gradlew build ? And did you see message that BUILD SUCCESSFULPhilippine
My mistake ./gradlew task buildPhilippine
First clean your project by ./gradlew task clean and after that call ./gradlew task build --debug | grep .apk from console you will see apk placePhilippine
./gradlew task build gives me a lint error: android { lintOptions { abortOnError false } }Kumar
P
3

First add

android { 

     compileSdkVersion 21
     buildToolsVersion "21.1.2"

     ...

     lintOptions { 
         abortOnError false 
     } 
}

in your build.gradle in app module.

After that clean your project by ./gradlew task clean and after that call ./gradlew task build --debug | grep .apk from console you will see apk place

Philippine answered 11/3, 2015 at 19:10 Comment(7)
Thanks, that fixed the build error, but the apks are still not made. In the output I see the following lines:12:14:13.906 [DEBUG] [org.gradle.api.Project] Packaging app-staging-release-unaligned.apk Output file /Users/jimwang/dev/test/AndroidAS/app/build/outputs/apk/app-staging-release.apk has changed. Output file /Users/jimwang/dev/test/AndroidAS/app/build/outputs/apk/app-staging-release.apk has been removed.Kumar
try cd /Users/jimwang/dev/test/AndroidAS/app/build/outputs/apkPhilippine
and ls -a after thatPhilippine
in console in your android studioPhilippine
there have to be these filesPhilippine
yes ur right, i was actually looking in the wrong folder that time. thanks !Kumar
I am glad that I could help you Good luckPhilippine
T
2

In Android Studio,

If the build is successful but not generating

.apk

file and not launching emulator.

Solution: Make sure the drop-down below build in menu or drop-down to left side of the run is selected to 'app' then when you run or debug,

.apk

file will be generated and the emulator will launch.

Tailing answered 16/7, 2017 at 14:9 Comment(1)
"Make sure the drop-down below build in menu or drop-down to left side of the run is selected to 'app' then when you run or debug," I don't find anything that looks like this.Volkslied

© 2022 - 2024 — McMap. All rights reserved.