Skip to content

Commit

Permalink
* fix packageName not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
lomanyong committed Sep 2, 2016
1 parent 5d728e2 commit 00930d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class FreelineInitializer {
projectDescription.main_r_path = FreelineGenerator.generateMainRPath(projectDescription.build_directory.toString(), productFlavor, projectDescription.package.toString())

if (packageName == null || packageName == '') {
projectDescription.package = project.android.defaultConfig.applicationId.toString()
projectDescription.package = getPackageName(project.android.defaultConfig.applicationId.toString(), projectDescription.main_manifest_path)
projectDescription.debug_package = projectDescription.package
}

Expand Down Expand Up @@ -214,6 +214,13 @@ class FreelineInitializer {
return dir.exists() && dir.isDirectory()
}

private static String getPackageName(String applicationId, String manifestPath) {
if (!FreelineUtils.isEmpty(applicationId) && !"null".equals(applicationId)) {
return applicationId
}
return FreelineParser.getPackage(manifestPath)
}

private static String getJavaHome() {
String env = System.getenv("JAVA_HOME")
if (env == null || "".equals(env)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ package com.antfortune.freeline
*/
class FreelineParser {

public static String getPackage(String manifestPath) {
def packageName = ""
def manifestFile = new File(manifestPath)
if (manifestFile.exists() && manifestFile.isFile()) {
def manifest = new XmlSlurper(false, false).parse(manifestFile)
packageName = manifest."@package"
}
return packageName
}

public static String getLauncher(String manifestPath, String packageName) {
def launcher = ""
def manifestFile = new File(manifestPath)
Expand Down

0 comments on commit 00930d2

Please sign in to comment.