Merge change 627 into donut

* changes:
  Fix a bunch of issues related to packaging the content of libs (NPE with files with no extension, not ignoring ignorable folders). Also fixed an issue when parsing Manifest with <uses-sdk />
This commit is contained in:
Android (Google) Code Review
2009-04-28 11:02:14 -07:00
4 changed files with 33 additions and 10 deletions

View File

@@ -907,6 +907,21 @@ public class ApkBuilder extends BaseBuilder {
AdtPlugin.printErrorToConsole(javaProject.getProject(), msg);
markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
return false;
} catch (Exception e) {
// try to catch other exception to actually display an error. This will be useful
// if we get an NPE or something so that we can at least notify the user that something
// went wrong (otherwise the build appears to succeed but the zip archive is not closed
// and therefore invalid.
String msg = e.getMessage();
if (msg == null) {
msg = e.getClass().getCanonicalName();
}
msg = String.format("Unknown error: %1$s", msg);
AdtPlugin.printErrorToConsole(javaProject.getProject(), msg);
markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
return false;
} finally {
if (fos != null) {
try {
@@ -943,7 +958,8 @@ public class ApkBuilder extends BaseBuilder {
IPath path = resource.getFullPath();
// check the extension.
if (path.getFileExtension().equalsIgnoreCase(AndroidConstants.EXT_NATIVE_LIB)) {
String ext = path.getFileExtension();
if (ext != null && ext.equalsIgnoreCase(AndroidConstants.EXT_NATIVE_LIB)) {
// remove the first segment to build the path inside the archive.
path = path.removeFirstSegments(rootSegmentCount);
@@ -954,7 +970,8 @@ public class ApkBuilder extends BaseBuilder {
// writes the file in the apk.
jarBuilder.writeFile(resource.getLocation().toFile(), apkPath.toString());
}
} else if (resource.getType() == IResource.FOLDER) {
} else if (resource.getType() == IResource.FOLDER &&
checkFolderForPackaging((IFolder)resource)) {
IResource[] members = ((IFolder)resource).members();
for (IResource member : members) {
writeNativeLibraries(rootSegmentCount, jarBuilder, member);

View File

@@ -271,8 +271,7 @@ public class PreCompilerBuilder extends BaseBuilder {
// if there was some XML errors, we just return w/o doing
// anything since we've put some markers in the files anyway.
if (dv != null && dv.mXmlError) {
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, project,
Messages.Xml_Error);
AdtPlugin.printErrorToConsole(project, Messages.Xml_Error);
// This interrupts the build. The next builders will not run.
stopBuild(Messages.Xml_Error);

View File

@@ -334,10 +334,12 @@ public class AndroidManifestParser {
value = getAttributeValue(attributes, ATTRIBUTE_MIN_SDK_VERSION,
true /* hasNamespace */);
try {
mApiLevelRequirement = Integer.parseInt(value);
} catch (NumberFormatException e) {
handleError(e, -1 /* lineNumber */);
if (value != null) {
try {
mApiLevelRequirement = Integer.parseInt(value);
} catch (NumberFormatException e) {
handleError(e, -1 /* lineNumber */);
}
}
} else if (NODE_INSTRUMENTATION.equals(localName)) {
processInstrumentationNode(attributes);

View File

@@ -109,17 +109,22 @@ public class XmlErrorHandler extends DefaultHandler {
mErrorListener.errorFound();
}
String message = exception.getMessage();
if (message == null) {
message = "Unknown error " + exception.getClass().getCanonicalName();
}
if (mFile != null) {
if (lineNumber != -1) {
BaseProjectHelper.addMarker(mFile,
AndroidConstants.MARKER_XML,
exception.getMessage(),
message,
lineNumber,
IMarker.SEVERITY_ERROR);
} else {
BaseProjectHelper.addMarker(mFile,
AndroidConstants.MARKER_XML,
exception.getMessage(),
message,
IMarker.SEVERITY_ERROR);
}
}