使用最新android sdk 将jar文件编译成dex

最近需要一些比较骚的操作,所以需要将gson编译成dex。

因为手上有jar包,所以就拿出了android sdk准备一把入魂,结果报错不断,让人无奈。只好根据报错来调整编译步骤,不得不为安卓环境更新Debug。

1、dx变d8

并不确定安卓更名的原因,但找到这个只是根据名字前面有个相同的d,这对于不太熟悉更新的人来说,只能靠蒙。

并不确定从哪个版本开始,dx.bat更新成了d8.bat。而且在使用中,命令方式也发生了变化,这个后面再讲。

所以,原来的dx --dex --output xxx.dex xxx.jar命令,不能使用了。

2、jre环境报错。

日常使用java的人,我觉得大多数人还是使用1.8。

不过随着各种软件,及编译环境的更新,java1.8的问题慢慢出现了,也出现了各种不兼容的情况。

只是到目前为止,还没有更新的动力。

这次编译,报错了:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/tools/r8/D8 has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0at java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClass(Unknown Source)at java.security.SecureClassLoader.defineClass(Unknown Source)at java.net.URLClassLoader.defineClass(Unknown Source)at java.net.URLClassLoader.access$100(Unknown Source)at java.net.URLClassLoader$1.run(Unknown Source)at java.net.URLClassLoader$1.run(Unknown Source)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(Unknown Source)at java.lang.ClassLoader.loadClass(Unknown Source)at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)at java.lang.ClassLoader.loadClass(Unknown Source)at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

报错就是说java1.8太老了,带不动了。

所以,切换java版本,运行了,继续报错。

3、命令换了

C:\Users\Administrator\Desktop\gson>d8
Exception in thread "main" java.lang.RuntimeException: Invalid invocation.
Usage: d8 [options] [@<argfile>] <input-files>where <input-files> are any combination of dex, class, zip, jar, or apk filesand each <argfile> is a file containing additional arguments (one per line)and options are:--debug                 # Compile with debugging information (default).--release               # Compile without debugging information.--output <file>         # Output result in <file>.# <file> must be an existing directory or a zip file.--lib <file|jdk-home>   # Add <file|jdk-home> as a library resource.--classpath <file>      # Add <file> as a classpath resource.--min-api <number>      # Minimum Android API level compatibility (default: 1).--pg-map <file>         # Use <file> as a mapping file for distribution.--intermediate          # Compile an intermediate result intended for later# merging.--file-per-class        # Produce a separate dex file per class.# Synthetic classes are in their own file.--file-per-class-file   # Produce a separate dex file per input .class file.# Synthetic classes are with their originating class.--no-desugaring         # Force disable desugaring.--desugared-lib <file>  # Specify desugared library configuration.# <file> is a desugared library configuration (json).--desugared-lib-pg-conf-output <file># Output the Proguard configuration for L8 to <file>.--main-dex-rules <file> # Proguard keep rules for classes to place in the# primary dex file.--main-dex-list <file>  # List of classes to place in the primary dex file.--main-dex-list-output <file># Output resulting main dex list in <file>.--force-enable-assertions[:[<class name>|<package name>...]]--force-ea[:[<class name>|<package name>...]]# Forcefully enable javac generated assertion code.--force-disable-assertions[:[<class name>|<package name>...]]--force-da[:[<class name>|<package name>...]]# Forcefully disable javac generated assertion code.# This is the default handling of javac assertion code# when generating DEX file format.--force-passthrough-assertions[:[<class name>|<package name>...]]--force-pa[:[<class name>|<package name>...]]# Don't change javac generated assertion code. This# is the default handling of javac assertion code when# generating class file format.--force-assertions-handler:<handler method>[:[<class name>|<package name>...]]--force-ah:<handler method>[:[<class name>|<package name>...]]# Change javac and kotlinc generated assertion code# to invoke the method <handler method> with each# assertion error instead of throwing it.# The <handler method> is specified as a class name# followed by a dot and the method name.# The handler method must take a single argument of# type java.lang.Throwable and have return type void.--thread-count <number> # Use <number> of threads for compilation.# If not specified the number will be based on# heuristics taking the number of cores into account.--map-diagnostics[:<type>] <from-level> <to-level># Map diagnostics of <type> (default any) reported as# <from-level> to <to-level> where <from-level> and# <to-level> are one of 'info', 'warning', or 'error'# and the optional <type> is either the simple or# fully qualified Java type name of a diagnostic.# If <type> is unspecified, all diagnostics at# <from-level> will be mapped.# Note that fatal compiler errors cannot be mapped.--android-platform-build# Compile as a platform build where the runtime/bootclasspath# is assumed to be the version specified by --min-api.--art-profile <input> <output># Rewrite human readable ART profile read from <input> and write to <output>.--startup-profile <file># Startup profile <file> to use for dex layout.--version               # Print the version of d8.--help                  # Print this message.

最显著的变化有两个:

1、不再需要 --dex 命令

2、不能直接转化成.dex文件,需要zip或者jar后缀。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/74855.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Undefined symbols for architecture arm64

解决问题之前&#xff0c;先了解清晰涉及到的知识点&#xff1a; iOS支持的指令集包含&#xff1a;armv6、armv7、armv7s、arm64&#xff0c;在项目TARGETS---->Build Settings--->Architecturs 可以修改对应的指令集&#xff0c;目前Standard Architectures(arm64, arm…

Windows MySQL服务安装及问题解决方案

Windows MySQL服务安装及问题解决方案 安装及配置步骤一&#xff1a;官网下网MySQL安装包步骤二&#xff1a;设置环境变量步骤仨&#xff1a;配置MySQL,ini配置文件步骤四&#xff1a;初始化MySQL步骤五&#xff1a;开启MySQL服务步骤六&#xff1a;测试是否安装成功步骤七&…

CMS指纹识别

一.什么是指纹识别 常见cms系统 通过关键特征&#xff0c;识别出目标的CMS系统&#xff0c;服务器&#xff0c;开发语言&#xff0c;操作系统&#xff0c;CDN&#xff0c;WAF的类别版本等等 1.识别对象 1.CMS信息&#xff1a;比如Discuz,织梦&#xff0c;帝国CMS&#xff0…

【SpringMVC】Jrebel 插件实现热部署与文件上传

目录 一、JRebel 1.1 Jrebel介绍 1.2 Jrebel插件下载 1.3 Jrebel服务下载并启动 1.4 在线生成GUID 1.5 JRebel激活 1.6 相关设置 注意❗ 二、文件上传、下载 2.1 导入pom依赖 2.2 配置文件上传解析器 2.3 文件上传表单设置 2.4 文件上传实现 2.5 文件下载实现 2…

代码随想录算法训练营第十八天|513. 找树左下角的值|112. 路径总和|106. 从中序与后序遍历序列构造二叉树

513. 找树左下角的值 题目&#xff1a;给定一个二叉树的 根节点 root&#xff0c;请找出该二叉树的 最底层 最左边 节点的值。 假设二叉树中至少有一个节点。 示例 1: 输入: root [2,1,3] 输出: 1 思路一&#xff1a;层序遍历&#xff0c;最后一层的第一个元素&#xff0c;即…

基于51单片机DS18B20温度及电流检测-proteus仿真-源程序

一、系统方案 本设计采用52单片机作为主控器&#xff0c;液晶1602显示&#xff0c;DS18B20检测温度&#xff0c;电流检测。 二、硬件设计 原理图如下&#xff1a; 三、单片机软件设计 1、首先是系统初始化 void lcd_init() //lcd 初始化设置子函数&#xff0c;不带参数 ,0x…

持安科技入选数说安全《2023中国网络安全市场年度报告》

近日&#xff0c;网络安全产业研究平台数说安全发布《2023中国网络安全市场年度报告》&#xff0c;报告共分为158页核心报告&#xff0c;及番外篇《网安融资新星及融资过亿企业介绍》&#xff0c;作为以甲方身份创业的零信任办公安全明星企业&#xff0c;持安科技以网安融资新星…

MATLAB R2023a完美激活版(附激活补丁)

MATLAB R2023a是一款面向科学和工程领域的高级数学计算和数据分析软件&#xff0c;它为Mac用户提供了强大的工具和功能&#xff0c;用于解决各种复杂的数学和科学问题。以下是MATLAB R2023a Mac的一些主要特点和功能&#xff1a; 软件下载&#xff1a;MATLAB R2023a完美激活版 …

select多选回显问题 (取巧~)

要实现的效果&#xff1a; 实际上select选择框&#xff0c;我想要的是数组对象&#xff0c;但是后端返回来的是个字符串。 以下是解决方法&#xff1a; 以上是一种简单的解决方法~ 也可以自己处理数据或者让后端直接改成想要的格式。

Kafka3.0.0版本——消费者(手动提交offset)

目录 一、消费者&#xff08;手动提交 offset&#xff09;的概述1.1、手动提交offset的两种方式1.2、手动提交offset两种方式的区别1.3、手动提交offset的图解 二、消费者&#xff08;手动提交 offset&#xff09;的代码示例2.1、手动提交 offset&#xff08;采用同步提交的方式…

Python爬虫 教程:IP池的使用

前言 嗨喽~大家好呀&#xff0c;这里是魔王呐 ❤ ~! python更多源码/资料/解答/教程等 点击此处跳转文末名片免费获取 一、简介 爬虫中为什么需要使用代理 一些网站会有相应的反爬虫措施&#xff0c;例如很多网站会检测某一段时间某个IP的访问次数&#xff0c;如果访问频率…

[SICTF 2023 #Round2] Crypto,PWN,Reverse

似乎很久没写了。 周五到周日&#xff0c;两天的这个比赛&#xff0c;有些东西还真是头回用&#xff0c;值得纪录一下。 Crypto 密码这块这届还是比较简单的&#xff0c;没有复杂的题&#xff0c;但量大分多。 【签到】古典大杂烩 给了一堆emoji的图 &#x1f429;&#x…

GCP Architect之VPN+Network

VPN 搜索结果共计:11 [单选]As part of implementing their disaster recovery plan, your company is trying to replicate their production MySQL database from their private data center to their GCP project using a Google Cloud VPN connection. They are experien…

OpenCV(三十四):轮廓外接最大、最小矩形和多边形拟合

目录 1.轮廓外接最大矩形boundingRect() 2.轮廓外接最小矩形minAreaRect() 3.轮廓外接多边形approxPolyDP() 1.轮廓外接最大矩形boundingRect() Rect cv::boundingRect ( InputArray array ) array:输入的灰度图像或者2D点集&#xff0c;数据类型为vector<Point>或者M…

Go语言的[GPM模型]

在go中,线程是运行Groutine的实体,调度器的功能是把可以运行的Groutine分配到工作线程上 GPM模型 M与P的数量没有绝对的数量关系,当一个M阻塞时,P就会创建一个或者切换到另一个M,所以即使设置了runtime.GOMAXPROCS(1) 也可能创建多个M出来; 当M发现给自己输送G协程的那个P队列为…

《AI一键生成抖音商品种草文案》让你秒变带货王!

在这个数字化的时代&#xff0c;我们的生活被各种应用所包围&#xff0c;其中&#xff0c;抖音作为一款短视频分享平台&#xff0c;已经成为了我们生活中不可或缺的一部分。然而&#xff0c;作为一名抖音创作者&#xff0c;你是否曾经遇到过这样的困扰&#xff1a;在创作商品种…

C#程序到底从哪里开始看,从Main函数开始,那么Main函数是什么?

视觉人机器视觉粉丝问我,拿到自己公司得架构,问我,C#程序到底从哪里看,从Main函数开始,那么Main函数是什么? Main()函数 Main()是C#应用程序的入口点,执行这个函数就是执行应用程序。也就是说,在执行过程开始时,会执行Main()函数,在Main()函数执行完毕时,执行过…

【JavaSpring】spring接口-beanfactory和applicationcontext与事件解耦

beanfactory 1.applicationcontext的父接口 2.是Spring的核心容器 功能 表面只有getBean&#xff0c;但实现类默默发挥了巨大作用 1.管理所有bean 2.控制反转 3.基本的依赖注入 applicationcontext 功能 1.继承了MessageSource&#xff0c;有了处理国际化资源的能力 …

[H5动画制作系列] Sprite及Text Demo

参考代码: sprite.js: var canvas, stage, container; canvas document.getElementById("mainView"); function init() {stage new createjs.Stage(canvas);createjs.Touch.enable(stage);var loader new createjs.LoadQueue(false);loader.addEventListener(&q…

云计算与虚拟化

一、概念 什么是云计算&#xff1f; 云计算&#xff08;cloud computing&#xff09;是分布式计算的一种&#xff0c;指的是通过网络“云”将巨大的数据计算处理程序分解成无数个小程序&#xff0c;然后&#xff0c;通过多部服务器组成的系统进行处理和分析这些小程序得到结果…