public final class SymbolUtils
extends java.lang.Object
| Constructor and Description |
|---|
SymbolUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
canonicalizeValueResourceName(java.lang.String name)
Updates the value resource name to mimic aapt's behaviour - replaces all dots and colons with
underscores.
|
static java.util.List<java.lang.String> |
generateMainDexKeepRules(ManifestData manifest,
java.io.File mergedResources)
Generates keep rules based on the nodes declared in the manifest file.
|
static java.util.List<java.lang.String> |
generateMinifyKeepRules(ManifestData manifest,
java.io.File mergedResources)
Generates keep rules based on the nodes declared in the manifest file.
|
static java.lang.String |
getPackageNameFromManifest(java.io.File manifestFile)
Pulls out the package name from the given android manifest.
|
static java.lang.String |
getPackageNameFromManifest(ManifestData manifest)
Pulls out the package name from the given parsed android manifest.
|
static java.util.Set<com.android.ide.common.symbols.SymbolTable> |
loadDependenciesSymbolTables(java.lang.Iterable<java.io.File> libraries)
Load symbol tables of each library on which the main library/application depends on.
|
static com.android.ide.common.symbols.SymbolTable |
mergeAndRenumberSymbols(java.lang.String mainPackageName,
com.android.ide.common.symbols.SymbolTable librarySymbols,
java.util.Set<com.android.ide.common.symbols.SymbolTable> dependencySymbols,
com.android.ide.common.symbols.SymbolTable platformSymbols) |
static ManifestData |
parseManifest(java.io.File manifestFile) |
@NonNull
public static com.android.ide.common.symbols.SymbolTable mergeAndRenumberSymbols(@NonNull
java.lang.String mainPackageName,
@NonNull
com.android.ide.common.symbols.SymbolTable librarySymbols,
@NonNull
java.util.Set<com.android.ide.common.symbols.SymbolTable> dependencySymbols,
@NonNull
com.android.ide.common.symbols.SymbolTable platformSymbols)
@NonNull
public static java.util.Set<com.android.ide.common.symbols.SymbolTable> loadDependenciesSymbolTables(@NonNull
java.lang.Iterable<java.io.File> libraries)
throws java.io.IOException
libraries - libraries which the main library/application depends onjava.io.IOException@NonNull
public static java.lang.String getPackageNameFromManifest(@NonNull
java.io.File manifestFile)
throws java.io.IOException
manifestFile - manifest file of the libraryjava.io.IOException - if there is a problem reading the manifest or if the manifest does not
contain a package name@NonNull
public static java.lang.String getPackageNameFromManifest(@NonNull
ManifestData manifest)
manifest - the parsed manifest of the librarypublic static java.util.List<java.lang.String> generateMinifyKeepRules(@NonNull
ManifestData manifest,
@Nullable
java.io.File mergedResources)
throws java.io.IOException
Used in the new resource processing, since aapt is not used in processing libraries'
resources and the aapt_rules.txt file and its rules are required by minify.
Goes through all application, instrumentation, activity, service, provider and receiver keep class data in the manifest, generates
keep rules for each of them and returns them as a list.
For examples refer to SymbolUtilsTest.java.
manifest - containing keep class datajava.io.IOExceptionpublic static java.util.List<java.lang.String> generateMainDexKeepRules(@NonNull
ManifestData manifest,
@Nullable
java.io.File mergedResources)
throws java.io.IOException
When AAPT2 is enabled, this method is called to generate manifest_keep.txt file
for Dex. Goes through all application, instrumentation, activity,
service, provider and receiver nodes and generates keep rules for
each of them, as long as the node doesn't declare it belongs to a private process. Returns
the keep rules as a list.
For examples refer to SymbolUtilsTest.java.
manifest - containing keep class datajava.io.IOExceptionpublic static ManifestData parseManifest(@NonNull java.io.File manifestFile) throws java.io.IOException
java.io.IOException@NonNull
public static java.lang.String canonicalizeValueResourceName(@NonNull
java.lang.String name)
If the name contains whitespaces or other illegal characters, they are not checked in this
method, but caught in the Symbol constructor call to Symbol.createAndValidateSymbol(ResourceType, String, SymbolJavaType, String, List).
name - the resource name to be updated