diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4bd8b7904 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ develop ] + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + cache: 'gradle' + + - name: Generate dependency graphs + uses: gradle/actions/dependency-submission@v3 + with: + dependency-graph: generate + + - name: Build dex-tools with Gradle + run: ./gradlew check distZip + + - name: Archive dex tools + uses: actions/upload-artifact@v4 + if: success() + with: + name: dex-tools + path: dex-tools/build/distributions/dex-tools-*.zip diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index c612e9dae..000000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,35 +0,0 @@ - -name: Java CI with Gradle - -on: - push: - branches: [ 2.x ] - tags: - - v* - pull_request: - branches: [ 2.x ] - workflow_dispatch: - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 - with: - java-version: '8' - distribution: 'temurin' - cache: 'gradle' - - name: Build dex-tools with Gradle - run: | - ./gradlew "-DGITHUB_REF_NAME=${GITHUB_REF_NAME}" check distZip - - - name: Archive dex tools - uses: actions/upload-artifact@v3 - if: success() - with: - name: dex-tools - path: dex-tools/build/distributions/dex-tools-*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..f24e0cbab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + cache: 'gradle' + + - name: Generate and submit dependency graphs + uses: gradle/actions/dependency-submission@v3 + with: + dependency-graph: generate-and-submit + + - name: Build dex-tools with Gradle + run: ./gradlew check -Pversion=2.4.${{ github.run_number }} distZip + + - uses: ncipollo/release-action@v1 + if: success() + with: + tag: 2.4.${{ github.run_number }} + artifacts: dex-tools/build/distributions/dex-tools-*.zip + + - name: Archive dex tools + uses: actions/upload-artifact@v4 + if: success() + with: + name: dex-tools + path: dex-tools/build/distributions/dex-tools-*.zip + + - name: Publish to Maven Central + run: ./gradlew -Pversion=2.4.${{ github.run_number }} publish closeAndReleaseStagingRepositories + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..626904be7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +*/target/* +target/* +*/build +build +*/.project +*/.classpath + +*.bak +*.orig +*/nb-configuration.xml +*.iml +*.ipr +*.iws +*~ +*.class + +.gradle +.idea +.vscode diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 67f92d3ee..000000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: java -jdk: -- openjdk8 diff --git a/LICENSE.txt b/LICENSE.txt index 43e91eb0b..4e111766d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,203 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 Panxiaobo + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE.txt b/NOTICE.txt index b0cdd56d6..6cf49ec1b 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,11 +1,11 @@ -dex2jar - Tools to work with android .dex and java .class files -Copyright (c) 2009-2014 Panxiaobo - -contributors - - Bob Pan - - HyperSpeeed - - Enea Stanzani - - t3stwhat - - paulhooijenga - - yyjdelete - - jcmdev0 +dex2jar - Tools to work with android .dex and java .class files +Copyright (c) 2009-2021 Panxiaobo + +contributors + - Bob Pan + - HyperSpeeed + - Enea Stanzani + - t3stwhat + - paulhooijenga + - yyjdelete + - jcmdev0 diff --git a/README.md b/README.md index 8523900cf..c079aaa2a 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,95 @@ # dex2jar -**Project move to [GitHub](https://github.com/pxb1988/dex2jar)** +

+ Workflow status +

-| _ | Mirror | Wiki | Downloads | Issues | -|--:|:-----|:----:|:---------:|:------:| -| gh | https://github.com/pxb1988/dex2jar | [Wiki](https://github.com/pxb1988/dex2jar/wiki) | [Releases](https://github.com/pxb1988/dex2jar/releases) | [Issues](https://github.com/pxb1988/dex2jar/issues) | -| sf | https://sourceforge.net/p/dex2jar | [old](https://sourceforge.net/p/dex2jar/wiki) | [old](https://sourceforge.net/projects/dex2jar/files/) | [old](https://sourceforge.net/p/dex2jar/tickets/) | -| bb | https://bitbucket.org/pxb1988/dex2jar | [old](https://bitbucket.org/pxb1988/dex2jar/wiki) | [old](https://bitbucket.org/pxb1988/dex2jar/downloads) | [old](https://bitbucket.org/pxb1988/dex2jar/issues) | -| gc | https://code.google.com/p/dex2jar | [old](http://code.google.com/p/dex2jar/w/list) | [old](http://code.google.com/p/dex2jar/downloads/list) | [old](http://code.google.com/p/dex2jar/issues/list)| +This is [Nico Mexis'](https://github.com/ThexXTURBOXx) fork of the dex2jar project which aims to fix most issues. + +## Fixed issues + +* Fixed many `StringIndexOutOfBoundsException`s relating to signatures +* Fixed `TypeTransformer` related issues +* Fixed many `NullPointerException`s and other crashes +* Fixed grammar of error messages +* Update libraries (especially ASM) +* Library fat-jar can be used for other projects (Automatically produced + by [GitHub Actions](https://github.com/ThexXTURBOXx/dex2jar/actions)) +* Smali now outputs `.param` instead of the outdated `.parameter` syntax +* Reformatted and cleaned up most of the code + +## Downloads + +This fork has builds available in the following formats.
+You can also only depend on a single module, if needed. The following sections include all the modules. + +### Maven + +The builds are available on [Maven Central](https://mvnrepository.com/artifact/de.femtopedia.dex2jar). + +```xml + + de.femtopedia.dex2jar + dex2jar + VERSION + +``` + +### Gradle + +The builds are available on [Maven Central](https://mvnrepository.com/artifact/de.femtopedia.dex2jar). + +```groovy +implementation 'de.femtopedia.dex2jar:dex2jar:VERSION' +``` + +### GitHub Releases + +To download the latest builds, head to the [Releases](https://github.com/ThexXTURBOXx/dex2jar/releases). + +**Note**: The builds in [Releases](https://github.com/ThexXTURBOXx/dex2jar/releases) are automatically built by GitHub +Actions. + +## Modules Tools to work with android .dex and java .class files 1. dex-reader/writer: - Read/write the Dalvik Executable (.dex) file. It has a [light weight API similar with ASM](https://sourceforge.net/p/dex2jar/wiki/Faq#markdown-header-want-to-read-dex-file-using-dex2jar). + Read/write the Dalvik Executable (.dex) file. It features + a [lightweight API similar with ASM](https://sourceforge.net/p/dex2jar/wiki/Faq/#want-to-read-dex-file-using-dex2jar) + . 2. d2j-dex2jar: - Convert .dex file to .class files (zipped as jar) + Convert .dex file to .class files (zipped as jar) 3. smali/baksmali: - disassemble dex to smali files and assemble dex from smali files. different implementation to [smali/baksmali](http://code.google.com/p/smali), same syntax, but we support escape in type desc "Lcom/dex2jar\t\u1234;" + Disassemble dex to smali files and assemble dex from smali files. Different implementation + to [smali/baksmali](http://code.google.com/p/smali), same syntax, but we support escape in type desc + `"Lcom/dex2jar\t\u1234;"` 4. other tools: - [d2j-decrypt-string](https://sourceforge.net/p/dex2jar/wiki/DecryptStrings) + [d2j-decrypt-string](https://sourceforge.net/p/dex2jar/wiki/DecryptStrings) ## Usage -1. In the root directory run: ./gradlew distZip -2. cd dex-tools/build/distributions -3. Unzip the file dex-tools-2.1-SNAPSHOT.zip (file size should be ~5 MB) -4. Run d2j-dex2jar.sh from the unzipped directory +1. In the root directory run: `./gradlew distZip` +2. `cd dex-tools/build/distributions` +3. Unzip the file `dex-tools-2.4-SNAPSHOT.zip` +4. Run `d2j-dex2jar.sh` from the unzipped directory ### Example usage: -> sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk + +```shell +sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk +``` And the output file will be `apk_to_decompile-dex2jar.jar`. +### Example Maven project: + +See for example the infamous [Bytecode Viewer](https://github.com/Konloch/bytecode-viewer). + ## Need help ? -post on issue trackers list above. + +Send an email to nico.mexis@kabelmail.de or post on the [issue tracker](https://github.com/ThexXTURBOXx/dex2jar/issues). ## License -[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) +[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..d790d083b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,17 @@ +# Security Policy + +## Supported Versions + +This fork does not release jars with proper semantic versioning as there +are not many breaking changes (if any) between the releases. + +For this reason, only the latest version is supported, and if there are +issues, they should also be tested with this version. + +## Reporting a Vulnerability + +Send me an email: nico.mexis@kabelmail.de + +I will try to respond to you as soon as possible (sometimes, it could +take some days, but I *will* contact you back; I have university and +am maintaining this fork in my free time). diff --git a/build.gradle b/build.gradle index 05f29255d..b783315fb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,91 +1,37 @@ -allprojects { - apply plugin: 'maven' - apply plugin: 'idea' - apply plugin: 'eclipse' - group = 'com.googlecode.d2j' - version = System.getProperty('GITHUB_REF_NAME', '2.x').replaceAll('[/ ]','-') +plugins { + id "base" + id "signing" + alias libs.plugins.nexus.publish + id "dex2jar.build-conventions" + alias libs.plugins.versions } -defaultTasks('clean','distZip') - -subprojects { - apply plugin: 'java' - apply plugin: 'maven' - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - - task packageSources(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource - } - artifacts.archives packageSources - repositories { - mavenCentral() - google() - } - -// == support provided scope - configurations { - provided - } - sourceSets { - main { compileClasspath += configurations.provided } - test { - compileClasspath += configurations.provided - } - } -// == end - - [compileJava, compileTestJava]*.options.collect {options ->options.encoding = 'UTF-8'} - - dependencies { - testCompile group: 'junit', name: 'junit', version:'4.11' - compile fileTree(dir: 'libs', include: '*.jar') - } - - jar { - manifest { - attributes("Implementation-Title": project.name, - "Implementation-Version": project.version, - "Build-Time": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - "Revision":"${getRevision()}", - "Build-Number": System.env.BUILD_NUMBER?System.env.BUILD_NUMBER:"-1", - ) - } - from (project.parent.projectDir) { - include 'NOTICE.txt' - include 'LICENSE.txt' - into('META-INF') +description = 'Supermodule for dex2jar' + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + var ossrhUsername = providers.environmentVariable("OSSRH_USERNAME") + var ossrhPassword = providers.environmentVariable("OSSRH_PASSWORD") + if (ossrhUsername.present && ossrhPassword.present) { + username.set(ossrhUsername.get()) + password.set(ossrhPassword.get()) + } + } } - } } -def getRevision() { - if (System.env.BUILD_REVISION) { - return System.env.BUILD_REVISION - } - if (System.env.GIT_REVISION) { - return System.env.GIT_REVISION - } - if (System.env.MERCURIAL_REVISION) { - System.env.MERCURIAL_REVISION - } - - def ver = null; - try { - ver = 'git rev-parse --short HEAD'.execute().text.trim() - } catch (e) { - // ignore - } - if (!ver) { - try { - ver = 'hg id -i -b -t'.execute().text.split(' ')[0]; - } catch (e) { - // ignore - } - } - if (!ver) { - ver = "HEAD" - } - return ver +dependencies { + api(project(":d2j-base-cmd")) + api project(path: ':d2j-external', configuration: 'shadow') + api(project(":d2j-jasmin")) + api(project(":d2j-smali")) + api(project(":dex-ir")) + api(project(":dex-reader")) + api(project(":dex-reader-api")) + api(project(":dex-tools")) + api(project(":dex-translator")) + api(project(":dex-writer")) } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000..678405245 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,3 @@ +plugins { + id 'groovy-gradle-plugin' +} diff --git a/buildSrc/src/main/groovy/dex2jar.build-conventions.gradle b/buildSrc/src/main/groovy/dex2jar.build-conventions.gradle new file mode 100644 index 000000000..d0081a8db --- /dev/null +++ b/buildSrc/src/main/groovy/dex2jar.build-conventions.gradle @@ -0,0 +1,126 @@ +plugins { + id 'java-library' + id 'maven-publish' + id 'signing' +} + +group = 'de.femtopedia.dex2jar' +version = project.findProperty('version') +version = version == null || version == 'unspecified' ? '2.4-SNAPSHOT' : version + +repositories { + mavenCentral() + google() +} + +jar { + manifest { + attributes('Implementation-Version': version) + } +} + +final javaVersion = JavaVersion.VERSION_1_8 +java { + sourceCompatibility = targetCompatibility = javaVersion + withSourcesJar() + withJavadocJar() +} + +javadoc { + options.encoding = 'UTF-8' + options.source = javaVersion.majorVersion +} + +dependencies { + testImplementation libs.junit.jupiter + testRuntimeOnly libs.junit.platform.launcher +} + +[compileJava, compileTestJava]*.options.collect { options -> + { + options.encoding = 'UTF-8' + options.release.set(javaVersion.majorVersion.toInteger()) + } +} + +signing { + var signingKey = providers.environmentVariable("GPG_SIGNING_KEY") + var signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE") + if (signingKey.present && signingPassphrase.present) { + useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get()) + sign publishing.publications + } +} + +// Workaround for https://github.com/gradle/gradle/issues/820 +configurations { + api { + extendsFrom = extendsFrom.findAll { it != configurations.antlr } + } +} + +// Workaround from https://github.com/gradle/gradle/issues/19555#issuecomment-1593252653 +try { + sourceSets.configureEach { + var generateGrammarSource = tasks.named(getTaskName("generate", "GrammarSource")) + java.srcDir(generateGrammarSource.map { files() }) + } +} catch (Throwable ignored) { +} + +test { + dependsOn ':d2j-external:shadowJar' + useJUnitPlatform() + systemProperty 'junit.jupiter.execution.parallel.enabled', true + systemProperty 'junit.jupiter.execution.parallel.mode.default', 'concurrent' +} + +afterEvaluate { + publishing { + publications { + mavenJava(MavenPublication) { + groupId = project.group.toString() + artifactId = project.name + version = project.version.toString() + if (project.name == "d2j-external") { + artifact(shadowJar) + artifact(sourcesJar) + artifact(javadocJar) + } else { + from(components.java) + } + pom { + name.set(project.name) + description.set(project.description) + url.set("https://github.com/ThexXTURBOXx/dex2jar") + licenses { + license { + name.set('The Apache License, Version 2.0') + url.set('https://www.apache.org/licenses/LICENSE-2.0.txt') + } + } + developers { + developer { + id.set("pxb1988") + name.set("Bob Pan") + email.set("pxb1988@gmail.com") + } + developer { + id.set("ThexXTURBOXx") + name.set("Nico Mexis") + email.set("nico.mexis@kabelmail.de") + } + } + scm { + url.set("https://github.com/ThexXTURBOXx/dex2jar.git") + connection.set("scm:git:git://github.com/ThexXTURBOXx/dex2jar.git") + developerConnection.set("scm:git:git://github.com/ThexXTURBOXx/dex2jar.git") + } + issueManagement { + url.set("https://github.com/ThexXTURBOXx/dex2jar/issues") + } + } + } + } + } +} diff --git a/d2j-base-cmd/build.gradle b/d2j-base-cmd/build.gradle index 85b5ae840..dfe25db0d 100644 --- a/d2j-base-cmd/build.gradle +++ b/d2j-base-cmd/build.gradle @@ -1,4 +1,9 @@ -description = 'a simple cmd parser' +plugins { + id "dex2jar.build-conventions" +} + +description = "Simple cmd parser for dex2jar" dependencies { + api project(path: ':d2j-external', configuration: 'shadow') } diff --git a/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java b/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java index b9c13eb8a..f020e22e8 100644 --- a/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java +++ b/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java @@ -1,19 +1,3 @@ -/* - * dex2jar - Tools to work with android .dex and java .class files - * Copyright (c) 2009-2012 Panxiaobo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.googlecode.dex2jar.tools; import java.io.File; @@ -27,12 +11,23 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; -import java.nio.file.*; +import java.nio.file.FileSystem; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.spi.FileSystemProvider; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; public abstract class BaseCmd { + public static String getBaseName(String fn) { int x = fn.lastIndexOf('.'); return x >= 0 ? fn.substring(0, x) : fn; @@ -43,9 +38,11 @@ public static String getBaseName(Path fn) { } public interface FileVisitorX { + // change the relative from Path to String // java.nio.file.ProviderMismatchException on jdk8 void visitFile(Path file, String relative) throws IOException; + } public static void walkFileTreeX(final Path base, final FileVisitorX fv) throws IOException { @@ -96,7 +93,7 @@ public static FileSystem openZip(Path in) throws IOException { for (FileSystemProvider p : FileSystemProvider.installedProviders()) { String s = p.getScheme(); if ("jar".equals(s) || "zip".equalsIgnoreCase(s)) { - return p.newFileSystem(in, new HashMap()); + return p.newFileSystem(in, new HashMap<>()); } } throw new IOException("cant find zipfs support"); @@ -117,8 +114,9 @@ public HelpException(String message) { } @Retention(value = RetentionPolicy.RUNTIME) - @Target(value = { ElementType.FIELD }) + @Target(value = {ElementType.FIELD}) public @interface Opt { + String argName() default ""; String description() default ""; @@ -130,15 +128,23 @@ public HelpException(String message) { String opt() default ""; boolean required() default false; + } - static protected class Option implements Comparable