use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AndroidLintTest method testGradlePlus.
/* Inspection disabled; these tests make network connection to MavenCentral and can change every time there
is a new version available (which makes for unstable tests)
public void testNewerAvailable() throws Exception {
GradleDetector.REMOTE_VERSION.setEnabledByDefault(true);
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintNewerVersionAvailableInspection(),
"Update to 17.0.0", "build.gradle", "gradle");
}
*/
public void testGradlePlus() throws Exception {
// Needs a valid SDK; can't use the mock one in the test data.
AndroidSdkData prevSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (prevSdkData == null) {
Sdk androidSdk = createLatestAndroidSdk();
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(androidSdk);
assertNotNull(androidPlatform);
// Put default platforms in the list before non-default ones so they'll be looked at first.
AndroidSdks.getInstance().setSdkData(androidPlatform.getSdkData());
}
//noinspection ConstantConditions
File sdk = AndroidSdks.getInstance().tryToChooseAndroidSdk().getLocation();
File appcompat = new File(sdk, "extras/android/m2repository/com/android/support/appcompat-v7/19.0.1".replace('/', File.separatorChar));
if (!appcompat.exists()) {
System.out.println("Not running " + this.getClass() + "#" + getName() + ": Needs SDK with Support Repo installed and " + "expected to find " + appcompat);
return;
}
// NOTE: The android support repository must be installed in the SDK used by the test!
doTestWithFix(new AndroidLintGradleDynamicVersionInspection(), "Replace with specific version", "build.gradle", "gradle");
AndroidSdks.getInstance().setSdkData(prevSdkData);
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class RenderErrorContributorTest method stripSdkHome.
private String stripSdkHome(@NotNull String html) {
AndroidPlatform platform = AndroidPlatform.getInstance(myModule);
assertNotNull(platform);
String location = platform.getSdkData().getLocation().getPath();
location = FileUtil.toSystemIndependentName(location);
html = html.replace(location, "$SDK_HOME");
return html;
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AndroidJunitPatcherTest method getExampleClasspath.
private List<String> getExampleClasspath() {
myRoot = normalize(myAndroidProject.getRootDir().getPath());
List<String> exampleClassPath = Lists.newArrayList(myRoot + "/build/intermediates/classes/debug", myRoot + "/build/intermediates/classes/test/debug", myRoot + "/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/classes.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/classes.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/libs/internal_impl-22.0.0.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/res", "/home/user/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar", "/idea/production/java-runtime", "/idea/production/junit_rt");
myMockableAndroidJar = myRoot + "/build/intermediates/mockable-" + TestUtils.getLatestAndroidPlatform() + ".jar";
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(myModule);
assertNotNull(androidPlatform);
myRealAndroidJar = TestUtils.getPlatformFile("android.jar").toString();
myResourcesDirs = ImmutableList.of(myRoot + "/build/intermediates/javaResources/debug", myRoot + "/build/intermediates/javaResources/test/debug");
exampleClassPath.add(0, myMockableAndroidJar);
exampleClassPath.add(0, myRealAndroidJar);
myExampleClassPathSet = ImmutableSet.copyOf(exampleClassPath);
// Sanity check. These should be fixed by the patcher.
assertContainsElements(exampleClassPath, myRealAndroidJar);
assertContainsElements(exampleClassPath, myMockableAndroidJar);
assertDoesntContain(exampleClassPath, myResourcesDirs);
assertFalse(Iterables.getLast(exampleClassPath).equals(myMockableAndroidJar));
return exampleClassPath;
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AddAndroidActivityPath method getDirectories.
private Map<String, Object> getDirectories() {
Map<String, Object> templateParameters = Maps.newHashMap();
Module module = getModule();
assert module != null;
AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
templateParameters.put(ATTR_BUILD_API, platform.getTarget().getVersion().getFeatureLevel());
templateParameters.put(ATTR_BUILD_API_STRING, getBuildApiString(platform.getTarget().getVersion()));
}
// Read minSdkVersion and package from manifest and/or build.gradle files
AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(facet);
AndroidModel androidModel = facet.getAndroidModel();
SourceProvider sourceProvider1 = myState.get(KEY_SOURCE_PROVIDER);
if (sourceProvider1 != null && androidModel != null) {
String packageName = myState.get(KEY_PACKAGE_NAME);
assert packageName != null;
templateParameters.putAll(selectSourceProvider(sourceProvider1, androidModel, module, packageName));
}
AndroidVersion minSdkVersion = moduleInfo.getMinSdkVersion();
String minSdkName = minSdkVersion.getApiString();
templateParameters.put(ATTR_MIN_API, minSdkName);
templateParameters.put(ATTR_TARGET_API, moduleInfo.getTargetSdkVersion().getApiLevel());
templateParameters.put(ATTR_MIN_API_LEVEL, minSdkVersion.getFeatureLevel());
templateParameters.put(ATTR_IS_LIBRARY_MODULE, facet.isLibraryProject());
try {
templateParameters.put(ATTR_DEBUG_KEYSTORE_SHA1, KeystoreUtils.sha1(getDebugKeystore(facet)));
} catch (Exception e) {
LOG.info("Could not compute SHA1 hash of debug keystore.", e);
templateParameters.put(ATTR_DEBUG_KEYSTORE_SHA1, "");
}
@SuppressWarnings("deprecation") String projectLocation = NewModuleWizardState.ATTR_PROJECT_LOCATION;
Project project = getProject();
assert project != null;
templateParameters.put(projectLocation, project.getBasePath());
// We're really interested in the directory name on disk, not the module name. These will be different if you give a module the same
// name as its containing project.
String moduleName = new File(module.getModuleFilePath()).getParentFile().getName();
templateParameters.put(FormFactorUtils.ATTR_MODULE_NAME, moduleName);
return templateParameters;
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class GraphicsLayoutRenderer method create.
/**
* Creates a new {@link GraphicsLayoutRenderer}.
* @param configuration The configuration to use when rendering.
* @param parser A layout pull-parser.
* @param backgroundColor If not null, this will be use to set the global Android window background
* @throws AlreadyDisposedException if the module is disposed while create is running
* @throws InitializationException if layoutlib fails to initialize.
* @throws UnsupportedLayoutlibException if the used layoutlib version is too old to run with this class
*/
@NotNull
public static GraphicsLayoutRenderer create(@NotNull Configuration configuration, @NotNull ILayoutPullParser parser, @Nullable Color backgroundColor, boolean hasHorizontalScroll, boolean hasVerticalScroll) throws InitializationException {
Module module = configuration.getModule();
if (module.isDisposed()) {
throw new AlreadyDisposedException("Module was already disposed");
}
AndroidFacet facet = AndroidFacet.getInstance(configuration.getModule());
if (facet == null) {
throw new InitializationException("Unable to get AndroidFacet");
}
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform == null) {
throw new UnsupportedLayoutlibException("No Android SDK found.");
}
SessionParams.RenderingMode renderingMode;
if (hasVerticalScroll && hasHorizontalScroll) {
renderingMode = SessionParams.RenderingMode.FULL_EXPAND;
} else if (hasVerticalScroll) {
renderingMode = SessionParams.RenderingMode.V_SCROLL;
} else if (hasHorizontalScroll) {
renderingMode = SessionParams.RenderingMode.H_SCROLL;
} else {
renderingMode = SessionParams.RenderingMode.NORMAL;
}
return create(facet, platform, module.getProject(), configuration, parser, backgroundColor, renderingMode, true);
}
Aggregations