java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/?
Posted
技术标签:
【中文标题】java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/?【英文标题】: 【发布时间】:2019-12-06 20:52:00 【问题描述】:我在 android app bundle 中遇到了这个问题。我已经从 android studio 3.4.2 成功创建了 android app bundle,现在我想使用 bundletool 从该 bundle 构建 apk,以便稍后我可以使用 bundletool 安装构建。但是当我运行这个从包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/??.
构建apks的命令时@
下面是日志。
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.lang.RuntimeException: ?
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: ?
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: ?
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)
所以,经过一番研究,我做了一个捆绑包,例如 myApp.aab,并将扩展名转换为生成 myApp.zip 的 .zip,然后我将其解压缩并转到上面日志中的文件夹(res /raw/) 并且还有很多包含 .xml 文件的文件。
但我注意到有很多 .xml 文件的名称在末尾包含空格,例如 -> 文件 .xml(在 e 之后包含空格)。然后我弄清楚了为什么会出现日志中的异常。
基本上,我正在使用 dexguard 混淆,它在混淆时在文件末尾留下空格。
现在我想知道如何预防?
【问题讨论】:
@Ahmed Izaz 您使用哪个工具进行混淆处理? 我们正在使用 DexGuard-8.3.15 进行混淆 确保使用最新版本的 dexguard。 @Pierre 我也尝试过最新的 Dexguard 8.4.15 但相同 嗯,我想我看到了问题所在。问题是 bundletool 和 DexGuard 的混合。 Bundletool 依赖文件系统来匹配文件,Windows fs 不支持 DexGuard 引入的字符。你能在bundletool issuetracker 上提交一个错误吗?我们可以试试看是否容易修复。 【参考方案1】:这似乎已在 Dexguard 8.5 中修复。
【讨论】:
以上是关于java.nio.file.InvalidPathException: Trailing char < > at index 10: res/raw/?的主要内容,如果未能解决你的问题,请参考以下文章