Skip to content

Commit 63affe0

Browse files
author
Mihail Slavchev
committed
fix renamed *.apk
1 parent c08b562 commit 63affe0

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

build/project-template-gradle/build.gradle

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def configStage = "\n:config phase: "
3939
def nodeModulesDir = "../../node_modules/"
4040
def libDir = "../../lib/Android/"
4141
def pluginNames = new ArrayList<String>()
42-
def configDir = file(nodeModulesDir)
42+
def configDir = file(configurationsDir)
4343
def appResExists = false
4444
def appResourcesName = "NativescriptAppResources"
4545

@@ -69,25 +69,24 @@ def computeBuildToolsVersion() {
6969
return "22.0.1"
7070
}
7171
}
72-
7372
project.ext.selectedBuildType = project.hasProperty("release") ? "release" : "debug"
7473

7574
def renameResultApks (variant) {
7675
def name
77-
variant.outputs.each { output ->
76+
variant.outputs.each { output ->
7877

79-
def apkDirectory = output.packageApplication.outputFile.parentFile
78+
def apkDirectory = output.packageApplication.outputFile.parentFile
8079
def apkNamePrefix = rootProject.name + "-" + variant.buildType.name
8180

82-
name = apkNamePrefix + "-unaligned.apk"
83-
output.packageApplication.outputFile = new File(apkDirectory, name);
84-
85-
if (output.packageApplication && (project.ext.selectedBuildType == variant.buildType.name)) {
86-
project.ext.currentApkFile = output.packageApplication.outputFile.getAbsolutePath().replace('\\', '/')
81+
if (output.zipAlign) {
82+
name = apkNamePrefix + ".apk"
83+
output.outputFile = new File(apkDirectory, name);
8784
}
88-
}
89-
}
9085

86+
name = apkNamePrefix + "-unaligned.apk"
87+
output.packageApplication.outputFile = new File(apkDirectory, name);
88+
}
89+
}
9190

9291
////////////////////////////////////////////////////////////////////////////////////
9392
///////////////////////////// CONFIGURATIONS ///////////////////////////////////////
@@ -391,7 +390,20 @@ task buildMetadata (type: JavaExec) {
391390
}
392391

393392
doLast {
394-
def tmpResourceAPK = new File("${buildDir}/intermediates/res/resources-${project.ext.selectedBuildType}.ap_")
393+
copy {
394+
from "metadata/output/assets/metadata"
395+
into "src/main/assets/metadata"
396+
}
397+
398+
def files = new File("${buildDir}/intermediates/res").listFiles()
399+
def tmpResourceAPK = null
400+
for (File f: files) {
401+
def name = f.getName();
402+
if (name.endsWith(".ap_")) {
403+
tmpResourceAPK = f;
404+
break;
405+
}
406+
}
395407

396408
def aaptCommand = "${android.getSdkDirectory().getAbsolutePath()}/build-tools/${android.buildToolsVersion}/aapt"
397409
if (isWinOs) {
@@ -477,3 +489,4 @@ task buildapk {
477489

478490
dependsOn deleteExplodedAarFolder
479491
}
492+

0 commit comments

Comments
 (0)