Merge branch 'cupcake'
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<classpathentry kind="lib" path="layoutlib_api.jar"/>
|
||||
<classpathentry kind="lib" path="layoutlib_utils.jar"/>
|
||||
<classpathentry kind="lib" path="ninepatch.jar"/>
|
||||
<classpathentry kind="lib" path="sdklib.jar"/>
|
||||
<classpathentry kind="lib" path="sdkuilib.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkUiLib"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -648,8 +648,11 @@ public class ApkBuilder extends BaseBuilder {
|
||||
return false;
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
String message = String.format(Messages.Dalvik_Error_s,
|
||||
ex.getMessage());
|
||||
String message = ex.getMessage();
|
||||
if (message == null) {
|
||||
message = ex.getClass().getCanonicalName();
|
||||
}
|
||||
message = String.format(Messages.Dalvik_Error_s, message);
|
||||
AdtPlugin.printErrorToConsole(getProject(), message);
|
||||
markProject(AdtConstants.MARKER_ADT, message, IMarker.SEVERITY_ERROR);
|
||||
if ((ex instanceof NoClassDefFoundError)
|
||||
|
||||
@@ -32,12 +32,12 @@ class AndroidClasspathContainer implements IClasspathContainer {
|
||||
/**
|
||||
* Constructs the container with the {@link IClasspathEntry} representing the android
|
||||
* framework jar file and the container id
|
||||
* @param entry the entry representing the android framework.
|
||||
* @param entries the entries representing the android framework and optional libraries.
|
||||
* @param path the path containing the classpath container id.
|
||||
* @param name the name of the container to display.
|
||||
*/
|
||||
AndroidClasspathContainer(IClasspathEntry entry, IPath path, String name) {
|
||||
mClasspathEntry = new IClasspathEntry[] { entry };
|
||||
AndroidClasspathContainer(IClasspathEntry[] entries, IPath path, String name) {
|
||||
mClasspathEntry = entries;
|
||||
mContainerPath = path;
|
||||
mName = name;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.android.ide.eclipse.adt.sdk.LoadStatus;
|
||||
import com.android.ide.eclipse.adt.sdk.Sdk;
|
||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -43,6 +44,9 @@ import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Classpath container initializer responsible for binding {@link AndroidClasspathContainer} to
|
||||
* {@link IProject}s. This removes the hard-coded path to the android.jar.
|
||||
@@ -141,7 +145,6 @@ public class AndroidClasspathContainerInitializer extends ClasspathContainerInit
|
||||
// just log the error
|
||||
AdtPlugin.log(ce, "Error removing target marker.");
|
||||
}
|
||||
|
||||
|
||||
// First we check if the SDK has been loaded.
|
||||
// By passing the javaProject to getSdkLoadStatus(), we ensure that, should the SDK
|
||||
@@ -255,15 +258,19 @@ public class AndroidClasspathContainerInitializer extends ClasspathContainerInit
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new {@link IClasspathEntry} object for the android
|
||||
* framework. <p/>This references the OS path to the android.jar and the
|
||||
* Creates and returns an array of {@link IClasspathEntry} objects for the android
|
||||
* framework and optional libraries.
|
||||
* <p/>This references the OS path to the android.jar and the
|
||||
* java doc directory. This is dynamically created when a project is opened,
|
||||
* and never saved in the project itself, so there's no risk of storing an
|
||||
* obsolete path.
|
||||
*
|
||||
* @param target The target that contains the libraries.
|
||||
*/
|
||||
private static IClasspathEntry createFrameworkClasspath(IAndroidTarget target) {
|
||||
private static IClasspathEntry[] createFrameworkClasspath(IAndroidTarget target) {
|
||||
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
|
||||
|
||||
// First, we create the IClasspathEntry for the framework.
|
||||
// now add the android framework to the class path.
|
||||
// create the path object.
|
||||
IPath android_lib = new Path(target.getPath(IAndroidTarget.ANDROID_JAR));
|
||||
@@ -278,14 +285,49 @@ public class AndroidClasspathContainerInitializer extends ClasspathContainerInit
|
||||
new Path("com/android/internal/**"), //$NON-NLS-1$
|
||||
IAccessRule.K_NON_ACCESSIBLE);
|
||||
|
||||
IClasspathEntry classpathEntry = JavaCore.newLibraryEntry(android_lib,
|
||||
IClasspathEntry frameworkClasspathEntry = JavaCore.newLibraryEntry(android_lib,
|
||||
android_src, // source attachment path
|
||||
null, // default source attachment root path.
|
||||
new IAccessRule[] { accessRule },
|
||||
new IClasspathAttribute[] { cpAttribute },
|
||||
false // not exported.
|
||||
);
|
||||
|
||||
list.add(frameworkClasspathEntry);
|
||||
|
||||
// now deal with optional libraries
|
||||
IOptionalLibrary[] libraries = target.getOptionalLibraries();
|
||||
if (libraries != null) {
|
||||
HashSet<String> visitedJars = new HashSet<String>();
|
||||
for (IOptionalLibrary library : libraries) {
|
||||
String jarPath = library.getJarPath();
|
||||
if (visitedJars.contains(jarPath) == false) {
|
||||
visitedJars.add(jarPath);
|
||||
|
||||
return classpathEntry;
|
||||
// create the java doc link, if needed
|
||||
String targetDocPath = target.getPath(IAndroidTarget.DOCS);
|
||||
IClasspathAttribute[] attributes = null;
|
||||
if (targetDocPath != null) {
|
||||
attributes = new IClasspathAttribute[] {
|
||||
JavaCore.newClasspathAttribute(
|
||||
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
|
||||
targetDocPath)
|
||||
};
|
||||
}
|
||||
|
||||
IClasspathEntry entry = JavaCore.newLibraryEntry(
|
||||
new Path(library.getJarPath()),
|
||||
null, // source attachment path
|
||||
null, // default source attachment root path.
|
||||
null,
|
||||
attributes,
|
||||
false // not exported.
|
||||
);
|
||||
list.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new IClasspathEntry[list.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,9 @@ public class Sdk {
|
||||
|
||||
/**
|
||||
* Returns a target from a hash that was generated by {@link IAndroidTarget#hashString()}.
|
||||
* @param hash the hash
|
||||
*
|
||||
* @param hash the {@link IAndroidTarget} hash string.
|
||||
* @return The matching {@link IAndroidTarget} or null.
|
||||
*/
|
||||
public IAndroidTarget getTargetFromHashString(String hash) {
|
||||
return mManager.getTargetFromHashString(hash);
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.android.ide.eclipse.common.AndroidConstants;
|
||||
import com.android.ide.eclipse.common.project.AndroidManifestHelper;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.project.ProjectProperties;
|
||||
import com.android.sdklib.project.ProjectProperties.PropertyType;
|
||||
import com.android.sdkuilib.SdkTargetSelector;
|
||||
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
@@ -129,6 +131,7 @@ public class NewProjectCreationPage extends WizardPage {
|
||||
protected boolean mProjectNameModifiedByUser;
|
||||
protected boolean mApplicationNameModifiedByUser;
|
||||
private boolean mInternalMinSdkVersionUpdate;
|
||||
private boolean mMinSdkVersionModifiedByUser;
|
||||
|
||||
|
||||
/**
|
||||
@@ -402,6 +405,7 @@ public class NewProjectCreationPage extends WizardPage {
|
||||
mSdkTargetSelector.setSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
onSdkTargetModified();
|
||||
updateLocationPathField(null);
|
||||
setPageComplete(validatePage());
|
||||
}
|
||||
@@ -735,6 +739,14 @@ public class NewProjectCreationPage extends WizardPage {
|
||||
try {
|
||||
int version = Integer.parseInt(getMinSdkVersion());
|
||||
|
||||
// Before changing, compare with the currently selected one, if any.
|
||||
// There can be multiple targets with the same sdk api version, so don't change
|
||||
// it if it's already at the right version.
|
||||
IAndroidTarget curr_target = getSdkTarget();
|
||||
if (curr_target != null && curr_target.getApiVersionNumber() == version) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IAndroidTarget target : mSdkTargetSelector.getTargets()) {
|
||||
if (target.getApiVersionNumber() == version) {
|
||||
mSdkTargetSelector.setSelection(target);
|
||||
@@ -744,6 +756,24 @@ public class NewProjectCreationPage extends WizardPage {
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
mMinSdkVersionModifiedByUser = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an SDK target is modified.
|
||||
*
|
||||
* If the minSdkVersion field hasn't been modified by the user yet, we change it
|
||||
* to reflect the sdk api level that has just been selected.
|
||||
*/
|
||||
private void onSdkTargetModified() {
|
||||
IAndroidTarget target = getSdkTarget();
|
||||
|
||||
if (target != null && !mMinSdkVersionModifiedByUser) {
|
||||
mInternalMinSdkVersionUpdate = true;
|
||||
mMinSdkVersionField.setText(Integer.toString(target.getApiVersionNumber()));
|
||||
mInternalMinSdkVersionUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -872,9 +902,22 @@ public class NewProjectCreationPage extends WizardPage {
|
||||
}
|
||||
}
|
||||
|
||||
// Select the target matching the manifest's sdk, if any
|
||||
// Select the target matching the manifest's sdk or build properties, if any
|
||||
boolean foundTarget = false;
|
||||
if (minSdkVersion != null) {
|
||||
|
||||
ProjectProperties p = ProjectProperties.create(projectLocation, null);
|
||||
if (p != null) {
|
||||
// Check the {build|default}.properties files if present
|
||||
p.merge(PropertyType.BUILD).merge(PropertyType.DEFAULT);
|
||||
String v = p.getProperty(ProjectProperties.PROPERTY_TARGET);
|
||||
IAndroidTarget target = Sdk.getCurrent().getTargetFromHashString(v);
|
||||
if (target != null) {
|
||||
mSdkTargetSelector.setSelection(target);
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundTarget && minSdkVersion != null) {
|
||||
try {
|
||||
int sdkVersion = Integer.parseInt(minSdkVersion);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user