private boolean checkContentTypes( @NonNull Set<ContentType> contentTypes, @NonNull Transform transform) { for (ContentType contentType : contentTypes) { if (!(contentType instanceof QualifiedContent.DefaultContentType || contentType instanceof ExtendedContentType)) { errorReporter.handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("Custom content types (%1$s) are not supported in transforms (%2$s)", contentType.getClass().getName(), transform.getName())); return false; } } return true; }
/** * Reports a warning. * * <p>Behaves similar to {@link #handleSyncError(String, int, String)} but does not abort the * build. * * @see #handleSyncError(String, int, String) */ @NonNull public final SyncIssue handleSyncWarning(@Nullable String data, int type, @NonNull String msg) { return handleIssue(data, type, SyncIssue.SEVERITY_WARNING, msg); } }
@SuppressWarnings({"UnusedParameters", "MethodMayBeStatic"}) public void setIncremental(boolean ignored) { mErrorReporter.handleSyncWarning( null, SyncIssue.TYPE_GENERIC, INCREMENTAL_IGNORED); }
/** * Check for user requested ABIs that aren't valid. Give a SyncIssue. */ private static void checkForRequestedButUnknownAbis ( @NonNull Collection<String> availableAbis, @NonNull Collection<String> userRequestedAbis, @NonNull AndroidBuilder androidBuilder, @NonNull String variantName) { List<String> requestedButNotAvailable = Lists.newArrayList(); for (String abiName : userRequestedAbis) { if (!availableAbis.contains(abiName)) { requestedButNotAvailable.add(abiName); } } if (!requestedButNotAvailable.isEmpty()) { androidBuilder.getErrorReporter().handleSyncError( variantName, SyncIssue.TYPE_EXTERNAL_NATIVE_BUILD_CONFIGURATION, String.format("ABIs [%s] are not available for platform and will be " + "excluded from building and packaging. Available ABIs are [%s].", Joiner.on(", ").join(requestedButNotAvailable), Joiner.on(", ").join(availableAbis))); } }
/** @deprecated ignored */ @SuppressWarnings("MethodMayBeStatic") @Deprecated public boolean getIncremental() { mErrorReporter.handleSyncWarning( null, SyncIssue.TYPE_GENERIC, INCREMENTAL_IGNORED); return false; }
/** * Reports an error. * * <p>The behavior of this method depends on whether the project is being evaluated by * an IDE or from the command line. If it's the former, the error will simply be recorder * and displayed after the sync properly finishes. If it's the latter, then the evaluation * is aborted right away. * * @param data a data representing the source of the error. This goes hand in hand with the * <var>type</var>, and is not meant to be readable. Instead a (possibly translated) * message is created from this data and type. * @param type the type of the error. * @param msg a human readable error (for command line output, or if an older IDE doesn't know * this particular issue type.) * @return a SyncIssue if the error is only recorded. * * @see SyncIssue */ @NonNull public final SyncIssue handleSyncError(@Nullable String data, int type, @NonNull String msg) { return handleIssue(data, type, SyncIssue.SEVERITY_ERROR, msg); }
public void build(boolean forceJsonGeneration) { try { diagnostic("building json with force flag %s", forceJsonGeneration); buildAndPropagateException(forceJsonGeneration); } catch (@NonNull IOException | GradleException e ) { androidBuilder.getErrorReporter().handleSyncError( variantName, SyncIssue.TYPE_EXTERNAL_NATIVE_BUILD_CONFIGURATION, e.getMessage()); } catch (ProcessException e) { androidBuilder.getErrorReporter().handleSyncError( e.getMessage(), SyncIssue.TYPE_EXTERNAL_NATIVE_BUILD_PROCESS_EXCEPTION, String.format("executing external native build for %s %s", getNativeBuildSystem().getName(), makefile)); } }
/** * @deprecated Dex will always be optimized. Invoking this method has no effect. */ @Deprecated public void setOptimize(@SuppressWarnings("UnusedParameters") Boolean optimize) { mErrorReporter.handleSyncWarning( null, SyncIssue.TYPE_GENERIC, OPTIMIZE_IGNORED + "\n" + OPTIMIZE_WARNING); } }
private boolean validateTransform(@NonNull Transform transform) { // check the content type are of the right Type. if (!checkContentTypes(transform.getInputTypes(), transform) || !checkContentTypes(transform.getOutputTypes(), transform)) { return false; } // check some scopes are not consumed. Set<? super Scope> scopes = transform.getScopes(); // Allow Jack transform to consume provided classes as the .jack files are needed. if (scopes.contains(Scope.PROVIDED_ONLY) && !isJackRuntimeLib(transform)) { errorReporter.handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("PROVIDED_ONLY scope cannot be consumed by Transform '%1$s'", transform.getName())); return false; } if (scopes.contains(Scope.TESTED_CODE)) { errorReporter.handleSyncError(null, SyncIssue.TYPE_GENERIC, String.format("TESTED_CODE scope cannot be consumed by Transform '%1$s'", transform.getName())); return false; } return true; }
@Deprecated public void setFlavorDimension(String dimension) { errorReporter.handleSyncWarning(null, SyncIssue.TYPE_GENERIC, "'flavorDimension' will be removed in a future version of Android Gradle Plugin, " + "it has been replaced by 'dimension'."); setDimension(dimension); }
errorReporter.handleSyncError( library.getName(), SyncIssue.TYPE_OPTIONAL_LIB_NOT_FOUND,
/** * Name of the dimension this product flavor belongs to. Has been replaced by * <code>dimension</code>. */ @Deprecated public String getFlavorDimension() { errorReporter.handleSyncWarning(null, SyncIssue.TYPE_GENERIC, "'flavorDimension' will be removed in a future version of Android Gradle Plugin, " + "it has been replaced by 'dimension'."); return getDimension(); }
resolvedConfiguration.rethrowFailure(); } catch (Exception e) { errorReporter.handleSyncError( "annotationProcessor", SyncIssue.TYPE_UNRESOLVED_DEPENDENCY,
androidBuilder.getErrorReporter().handleSyncWarning( scope.getFullVariantName(), SyncIssue.TYPE_EXTERNAL_NATIVE_BUILD_CONFIGURATION,
@NonNull public Set<File> resolveAndGetJackPluginClassPath( @NonNull ErrorReporter errorReporter) { if (getJackPluginConfiguration().getAllDependencies().isEmpty()) { return Collections.emptySet(); } ResolvedConfiguration resolvedConfiguration = getJackPluginConfiguration().getResolvedConfiguration(); if (resolvedConfiguration.hasError()) { try { resolvedConfiguration.rethrowFailure(); } catch (Exception e) { errorReporter.handleSyncError( "jackPlugin", SyncIssue.TYPE_UNRESOLVED_DEPENDENCY, "Unable to find Jack plugin. " + e.getMessage()); return Collections.emptySet(); } } return getJackPluginConfiguration().getFiles(); }
&& project.getPlugins().hasPlugin("com.neenbedankt.android-apt")) { errorReporter.handleSyncWarning( null, SyncIssue.TYPE_GENERIC,
/** * Sets the SdkInfo and the targetInfo on the builder. This is required to actually * build (some of the steps). * * @see com.android.builder.sdk.SdkLoader */ public void setTargetInfo(@NonNull TargetInfo targetInfo) { mTargetInfo = targetInfo; mDexByteCodeConverter = new DexByteCodeConverter( getLogger(), mTargetInfo, mJavaProcessExecutor, mVerboseExec); if (mTargetInfo.getBuildTools().getRevision().compareTo(MIN_BUILD_TOOLS_REV) < 0) { mErrorReporter.handleSyncError( MIN_BUILD_TOOLS_REV.toString(), SyncIssue.TYPE_BUILD_TOOLS_TOO_LOW, String.format( "The SDK Build Tools revision (%1$s) is too low for project '%2$s'. " + "Minimum required is %3$s", mTargetInfo.getBuildTools().getRevision(), mProjectId, MIN_BUILD_TOOLS_REV)); } }
if (Boolean.TRUE.equals(unbundledWearApp)) { if (hasWearAppDependency(variantData)) { androidBuilder.getErrorReporter().handleSyncError( scope.getFullVariantName(), SyncIssue.TYPE_DEPENDENCY_WEAR_APK_WITH_UNBUNDLED, androidBuilder.getErrorReporter().handleSyncError( configName, SyncIssue.TYPE_DEPENDENCY_WEAR_APK_TOO_MANY,
variantScope.getGlobalScope().getAndroidBuilder().getErrorReporter().handleSyncError( null, SyncIssue.TYPE_GENERIC,
errorReporter.handleSyncError( applicationId, SyncIssue.TYPE_GENERIC, String applicationIdSuffix = model.getDefaultConfig().getProductFlavor().getApplicationIdSuffix(); errorReporter.handleSyncError( applicationIdSuffix, SyncIssue.TYPE_GENERIC, if (buildType.getBuildType().getApplicationIdSuffix() != null) { String applicationIdSuffix = buildType.getBuildType().getApplicationIdSuffix(); errorReporter.handleSyncError( applicationIdSuffix, SyncIssue.TYPE_GENERIC, if (productFlavor.getProductFlavor().getApplicationId() != null) { String applicationId = productFlavor.getProductFlavor().getApplicationId(); errorReporter.handleSyncError( applicationId, SyncIssue.TYPE_GENERIC, String applicationIdSuffix = productFlavor.getProductFlavor().getApplicationIdSuffix(); errorReporter.handleSyncError( applicationIdSuffix, SyncIssue.TYPE_GENERIC, errorReporter.handleSyncError(