3

I am facing this issue in android app bundle. I have created the android app bundle from android studio 3.4.2 successfully and now i want to build apks from that bundle using bundletool so later i can install the build using the bundletool. But when I am running this command which build apks from the bundle java -jar bundletool-all-0.10.2.jar build-apks --bundle=D:\MyApp.aab --output=D:\all_apkk.apks --ks=keystorepath --ks-key-alias=aliasname --ks-pass=pass:pswrd. I am facing this Caused by: java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/??.

Here are the logs below.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/C:/Program%20Files/Java/jdk-11.0.2/bin/bundletool-all-0.10.2.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[BT:0.10.2] Error: java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/??
java.lang.RuntimeException: java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/??
        at com.android.tools.build.bundletool.io.ConcurrencyUtils.waitFor(ConcurrencyUtils.java:59)
        at com.android.tools.build.bundletool.io.ConcurrencyUtils.waitForAll(ConcurrencyUtils.java:42)
        at java.base/java.util.function.Function.lambda$andThen$1(Function.java:88)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:582)
        at com.android.tools.build.bundletool.io.ApkSerializerManager.serializeApks(ApkSerializerManager.java:180)
        at com.android.tools.build.bundletool.io.ApkSerializerManager.populateApkSetBuilder(ApkSerializerManager.java:101)
        at com.android.tools.build.bundletool.commands.BuildApksManager.executeWithZip(BuildApksManager.java:229)
        at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:110)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:524)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:74)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:46)
Caused by: java.util.concurrent.ExecutionException: java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/??
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:502)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:461)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83)
        at com.android.tools.build.bundletool.io.ConcurrencyUtils.waitFor(ConcurrencyUtils.java:49)
        ... 10 more
Caused by: java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/??
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:191)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
        at java.base/java.nio.file.Path.of(Path.java:147)
        at java.base/java.nio.file.Paths.get(Paths.java:69)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.lambda$shouldCompress$4(ApkSerializerHelper.java:309)
        at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
        at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
        at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:528)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.shouldCompress(ApkSerializerHelper.java:309)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.entryOptionForPath(ApkSerializerHelper.java:294)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.writeProtoApk(ApkSerializerHelper.java:254)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.writeToZipFile(ApkSerializerHelper.java:155)
        at com.android.tools.build.bundletool.io.ApkSerializerHelper.writeToZipFile(ApkSerializerHelper.java:144)
        at com.android.tools.build.bundletool.io.SplitApkSerializer.writeToDisk(SplitApkSerializer.java:75)
        at com.android.tools.build.bundletool.io.SplitApkSerializer.writeSplitToDisk(SplitApkSerializer.java:53)
        at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.addSplitApk(ApkSetBuilderFactory.java:105)
        at com.android.tools.build.bundletool.io.ApkSerializerManager$ApkSerializer.serialize(ApkSerializerManager.java:376)
        at com.android.tools.build.bundletool.io.ApkSerializerManager.lambda$null$3(ApkSerializerManager.java:184)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:117)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:38)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

So what I did after some research is I made a bundle e.g myApp.aab and convert the extension into the .zip which makes myApp.zip, Then I extract that and goes to the folder which is in the logs above (res/raw/) and there were a lot of files containing .xml files too.

But what I have noticed is there are alot of .xml file whose names contain space at the end e.g -> file .xml (containing space after e). Then I figured out that why the exception in logs coming.

Basically, I am using the dexguard obfuscation which is doing is leaving spaces at the end of the file while obfuscation.

Now I want to know how can i prevent it ?

Ahmad Izaz
  • 97
  • 3
  • 10
  • @Ahmed Izaz which tool you are using for Obfuscation? – Muhammad Waseem Jul 30 '19 at 11:48
  • 1
    we are using **DexGuard-8.3.15** for Obfuscation – Ahmad Izaz Jul 30 '19 at 11:52
  • Make sure you use the latest version of dexguard. – Pierre Jul 31 '19 at 08:49
  • @Pierre I have also tried with the latest which is **Dexguard 8.4.15** but same – Ahmad Izaz Jul 31 '19 at 09:14
  • Mhm, I think I see the problem. Problem is a mix of bundletool and DexGuard. Bundletool relies on the filesystem to match files, and Windows fs does not support characters introduced by DexGuard. Can you file a bug on [bundletool issuetracker](https://github.com/google/bundletool/issues)? We can try to see if it's easily fixable. – Pierre Jul 31 '19 at 16:26
  • As an alternative you can ask Dexguard not to use these special characters, which might be an easier fix. – Pierre Jul 31 '19 at 21:25
  • Someone mentioned that this was fixed in Dexguard 8.5: https://github.com/google/bundletool/issues/100#issuecomment-517345988 – Pierre Aug 01 '19 at 16:06
  • Yes @Pierre, I did report them that issue and they said that they will fix this and i received an email from them that we have fixed this in 8.5. – Ahmad Izaz Aug 01 '19 at 16:57

1 Answers1

0

This seems to have been fixed in Dexguard 8.5.

Pierre
  • 15,865
  • 4
  • 36
  • 50