Search code examples
androidgradlegradlew

Gradle does not generate an output APK


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"
    }
}

Solution

  • 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