我知道Android Studio switch to D8 dexer by default .但是我想知道d8.jar
的文件路径是什么? ?我找不到 d8.jar
在 SDK 中,如 dx.jar
.
一个典型的dx.jar
位于Android/Sdk/build-tools/<VERSION>/lib/
:
xb@dnxb:~/Android/Sdk/build-tools/27.0.3/lib$ ls
apksigner.jar dx.jar shrinkedAndroid.jar
xb@dnxb:~/Android/Sdk/build-tools/27.0.3/lib$
我的第一个想法是 dx.jar 表示 d8.jar,但似乎不是这样。
xb@dnxb:~/Downloads/dalvik/dx/src/com/android$ ls
dex dx multidex
xb@dnxb:~/Downloads/dalvik/dx/src/com/android$ ls -1 dex
Annotation.java
CallSiteId.java
ClassData.java
ClassDef.java
Code.java
DexException.java
DexFormat.java
DexIndexOverflowException.java
Dex.java
EncodedValueCodec.java
EncodedValue.java
EncodedValueReader.java
FieldId.java
Leb128.java
MethodHandle.java
MethodId.java
Mutf8.java
ProtoId.java
SizeOf.java
TableOfContents.java
TypeList.java
util
xb@dnxb:~/Downloads/dalvik/dx/src/com/android$
与dx.jar
的.classes完全一样在 27.0.3 或更早版本(例如 25.0.0)SDK 中(我将其解压缩):
xb@dnxb:~/Android/Sdk/build-tools/27.0.3/lib/dx/com/android$ ls
dex dx multidex
xb@dnxb:~/Android/Sdk/build-tools/27.0.3/lib/dx/com/android$ ls -1 dex | grep -v '\$'
Annotation.class
CallSiteId.class
ClassData.class
ClassDef.class
Code.class
Dex.class
DexException.class
DexFormat.class
DexIndexOverflowException.class
EncodedValue.class
EncodedValueCodec.class
EncodedValueReader.class
FieldId.class
Leb128.class
MethodHandle.class
MethodId.class
Mutf8.class
ProtoId.class
SizeOf.class
TableOfContents.class
TypeList.class
util
xb@dnxb:~/Android/Sdk/build-tools/27.0.3/lib/dx/com/android$
但是the new d8.jar具有完全不同的结构:
xb@dnxb:~/Downloads/r8/build/libs/d8/com/android/tools/r8$ ls
annotations ExtractMarkerCommand.class
ApiLevelException.class ExtractMarker$VdexOrigin.class
ArchiveClassFileProvider.class GenerateMainDexList.class
ArchiveProgramResourceProvider.class GenerateMainDexListCommand$1.class
ArchiveProgramResourceProvider$ZipFileSupplier.class GenerateMainDexListCommand$Builder.class
BaseCommand$Builder.class GenerateMainDexListCommand.class
BaseCommand.class graph
BaseCompilerCommand$Builder.class InternalProgramOutputPathConsumer.class
... omit
我在 sdk 和 Android Studio 中都使用 d8 关键字搜索文件名,但没有成功:
xb@dnxb:~$ find /home/xiaobai/Android/ -iname '*d8*'
xb@dnxb:~$ find ~/Downloads/AS/android-studio -iname '*d8*'
xb@dnxb:~$
那么d8.jar在Android Studio中的文件路径在哪里呢?我的 Android Studio 版本是 3.2 Canary 12
已经,但是如果 d8.jar 不存在,Android Studio 如何默认调用 d8?或者它隐藏在某个地方?
最佳答案
在构建工具 28.0.1 之前,D8/R8 并未像 dx 那样作为 Android SDK 的一部分分发。在最近的版本中有 build-tools/28.0.1/d8
和 build-tools/28.0.1/lib/d8.jar
。
它也作为 Android Gradle 插件的一部分提供。从 3.1.x/3.2-alpha 开始,D8 类(及其重新打包的依赖项)被捆绑到 com.android.tools.build:builder
工件中。后者是主要 gradle 插件工件的传递依赖。因此 Gradle 插件(以及 Android Studio)使用捆绑的 d8 类来 dex 代码。
有一个单独的工件 com.android.tools:r8
是一个单独的 R8 jar(没有依赖项,从版本 1.0.25 开始)但是 Android Gradle 插件不依赖于它.
关于android-studio - Android Studio 使用的d8.jar 的文件路径是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50080902/