@@ -181,6 +181,9 @@ private static class GradleAndroidManifestFinderStrategy extends AndroidManifest
181181
182182 static final Pattern GRADLE_GEN_FOLDER = Pattern .compile ("^(.*?)build[\\ \\ /]generated[\\ \\ /]source[\\ \\ /](k?apt)(.*)$" );
183183
184+ private static final List <String > SUPPORTED_ABI_SPLITS = Arrays .asList ("arm64-v8a" , "armeabi" , "armeabi-v7a" , "mips" , "mips64" , "x86" , "x86_64" );
185+ private static final List <String > SUPPORTED_DENSITY_SPLITS = Arrays .asList ("hdpi" , "ldpi" , "mdpi" , "xhdpi" , "xxhdpi" , "xxxhdpi" );
186+
184187 GradleAndroidManifestFinderStrategy (String sourceFolder ) {
185188 super ("Gradle" , GRADLE_GEN_FOLDER , sourceFolder );
186189 }
@@ -192,10 +195,6 @@ Iterable<String> possibleLocations() {
192195 String gradleVariant = matcher .group (3 );
193196 String variantPart = gradleVariant .substring (1 );
194197
195- if ("apt" .equals (mode )) {
196- return Arrays .asList ("build/intermediates/manifests/full" + gradleVariant , "build/intermediates/bundles" + gradleVariant , "build/intermediates/manifests/aapt" + gradleVariant );
197- }
198-
199198 ArrayList <String > possibleLocations = new ArrayList <>();
200199
201200 for (String directory : Arrays .asList ("build/intermediates/manifests/full" , "build/intermediates/bundles" , "build/intermediates/manifests/aapt" )) {
@@ -212,19 +211,45 @@ private void findPossibleLocations(String basePath, String targetPath, String va
212211 return ;
213212 }
214213
214+ if (variantPart .startsWith ("/" ) || variantPart .startsWith ("\\ " )) {
215+ variantPart = variantPart .substring (1 );
216+ }
217+
215218 for (String directory : directories ) {
216219 String possibleLocation = targetPath + "/" + directory ;
217220 File variantDir = new File (basePath + possibleLocation );
218221 if (variantDir .isDirectory () && variantPart .toLowerCase ().startsWith (directory .toLowerCase ())) {
219222 String remainingPart = variantPart .substring (directory .length ());
220223 if (remainingPart .length () == 0 ) {
221224 possibleLocations .add (possibleLocation );
225+ addPossibleSplitLocations (basePath , possibleLocation , possibleLocations );
222226 } else {
223227 findPossibleLocations (basePath , possibleLocation , remainingPart , possibleLocations );
224228 }
225229 }
226230 }
227231 }
232+
233+ private void addPossibleSplitLocations (String basePath , String possibleLocation , List <String > possibleLocations ) {
234+ for (String abiSplit : SUPPORTED_ABI_SPLITS ) {
235+ File splitDir = new File (basePath + possibleLocation + "/" + abiSplit );
236+ if (splitDir .isDirectory ()) {
237+ possibleLocations .add (possibleLocation + "/" + abiSplit );
238+ for (String densitySplit : SUPPORTED_DENSITY_SPLITS ) {
239+ File splitSubDir = new File (basePath + possibleLocation + "/" + abiSplit + "/" + densitySplit );
240+ if (splitSubDir .isDirectory ()) {
241+ possibleLocations .add (possibleLocation + "/" + abiSplit + "/" + densitySplit );
242+ }
243+ }
244+ }
245+ }
246+ for (String densitySplit : SUPPORTED_DENSITY_SPLITS ) {
247+ File splitDir = new File (basePath + possibleLocation + "/" + densitySplit );
248+ if (splitDir .isDirectory ()) {
249+ possibleLocations .add (possibleLocation + "/" + densitySplit );
250+ }
251+ }
252+ }
228253 }
229254
230255 private static class MavenAndroidManifestFinderStrategy extends AndroidManifestFinderStrategy {
0 commit comments