0

I am trying to Bundle my UE4 Android game in Android Studio so Google will finally accept it on the Play Store but am unfamiliar with Android Studio and have 1 code error preventing the code from Syncing.

applicationVariants.all {
      outputs.each {
          //directly write final APK to Binaries/Android with proper name
          it.outputFile = file(OUTPUT_PATH)
      }
}

The Code as shown generates this error

ERROR: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated... of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

Replacing outputFile with outputFileName results in this error

ERROR Absolute path are not supported when setting an output file name.

Ben P.
  • 1
  • 1

1 Answers1

0

From this

For Gradle 3.0+**

android {
...
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        applicationVariants.all { variant ->
            variant.outputs.all {
                def formattedDate = new Date().format('yyyyMMddHHmmss')
                def flavor = variant.name
                def versionName = variant.versionName
                outputFileName = "AppName_${versionName}_${flavor}_${formattedDate}.apk"
            }
        }
    }
}
...
}

Result :

AppName_release_1_20200121175123.apk

Nicasper
  • 66
  • 5