\r
package com.android.ide.eclipse.adt.internal.sourcelookup;\r
\r
-import com.android.ide.eclipse.adt.internal.project.AndroidClasspathContainerInitializer;\r
+import com.android.ide.eclipse.adt.internal.sdk.ProjectState;\r
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;\r
+import com.android.sdklib.IAndroidTarget;\r
\r
import org.eclipse.core.resources.IProject;\r
import org.eclipse.core.resources.ResourcesPlugin;\r
import org.eclipse.jdt.core.IJavaProject;\r
import org.eclipse.jdt.core.JavaCore;\r
import org.eclipse.jdt.internal.launching.JavaSourceLookupDirector;\r
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;\r
\r
import java.io.File;\r
\r
public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException {\r
dispose();\r
setLaunchConfiguration(configuration);\r
- String projectName = configuration.getAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", //$NON-NLS-1$\r
+ String projectName =\r
+ configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,\r
""); //$NON-NLS-1$\r
if (projectName != null && projectName.length() > 0) {\r
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);\r
if (project != null && project.isOpen()) {\r
+ ProjectState state = Sdk.getProjectState(project);\r
+ if (state == null) {\r
+ initDefaults();\r
+ return;\r
+ }\r
+ IAndroidTarget target = state.getTarget();\r
+ if (target == null) {\r
+ initDefaults();\r
+ return;\r
+ }\r
+ String path = target.getPath(IAndroidTarget.ANDROID_JAR);\r
+ if (path == null) {\r
+ initDefaults();\r
+ return;\r
+ }\r
IJavaProject javaProject = JavaCore.create(project);\r
if (javaProject != null && javaProject.isOpen()) {\r
- IClasspathEntry[] entries = javaProject.getRawClasspath();\r
+ IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);\r
IClasspathEntry androidEntry = null;\r
for (int i = 0; i < entries.length; i++) {\r
IClasspathEntry entry = entries[i];\r
- if (entry.getPath() != null\r
- && AndroidClasspathContainerInitializer.CONTAINER_ID.equals(entry\r
- .getPath().toString())) {\r
+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY\r
+ && path.equals(entry.getPath().toString())) {\r
androidEntry = entry;\r
break;\r
}\r
}\r
}\r
}\r
+ initDefaults();\r
+ }\r
+\r
+ private void initDefaults() {\r
setSourceContainers(new ISourceContainer[] {\r
new DefaultSourceContainer()\r
});\r