Your version is: java version "1.6.0_24". The correct version is: Java SE 1.6.

本文详细介绍了如何解决Android编译过程中遇到的错误,即使用不正确的Java版本。通过检查和更正Java SDK版本,确保了Android项目的顺利编译。包括在Ubuntu 12.04上安装最新版Sun JDK的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Wrong Java Version

I have the Java 6 OpenJDK, version 1.6.0_24. This meets the android Java requirement for 1.6.0, but I found (later in the build process) that Android really needs to be built by Sun’s Java SDK. In the meantime, the _24 suffix doesn’t check out in Android’s makefile, which produces the error  You are attempting to build with the incorrect version of java before exiting:

1
2
3
4
5
6
7
8
9
10
11
12
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_24".
The correct version is: Java SE 1.6.
Please follow the machine setup instructions at
    http://source.android.com/source/download.html
************************************************************
build/core/main.mk:131: *** stop.  Stop.

你可能之前安装过jdk1.6.0_33或其他版本,此时查看jdk 版本,

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

发现版本变成了OpenJDK,下文红色部分可以将更正jdk版本,使编译通过

make will display the error message, but continue compiling. However, compiling with OpenJDK will probably create problems later in the build process(in out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar). To fix the problems, Sun’s Java SDK will need to be installed.

Installing the Sun Java 6 JDK in Ubuntu 12.04

To fix the make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41, get the most recent Sun JDK from here. Once you’ve downloaded it, install it and run update-alternatives so your system uses the Sun JDK:

zhoulc@zhoulc-PC:~/work/tools $ chmod +x jdk-6u33-linux-x64.bin
zhoulc@zhoulc-PC:~/work/tools $ sudo ./jdk-6u33-linux-x64.bin

zhoulc@zhoulc-PC:~/work/tools$ sudo mv jdk1.6.0_33/ /usr/lib/jvm/
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/jdk1.6.0_33/bin/java                1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/java to provide /usr/bin/java (java) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-amd64/bin/javac   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/bin/javac   1061      manual mode
  2            /usr/lib/jvm/jdk1.6.0_33/bin/javac            1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/javac to provide /usr/bin/javac (javac) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).

  Selection    Path                                              Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws   1060      manual mode
  3            /usr/lib/jvm/jdk1.6.0_33/bin/javaws                1         manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/javaws to provide /usr/bin/javaws (javaws) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$


To verify that the installation was successful, check Java’s version. It should now show that the Sun JDK is running instead of IcedTea:

zhoulc@zhoulc-PC:~/work/tools $ java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)

To revert the changes after Android has been compiled, run update-alternatives to switch back to OpenJDK.

a1@1:~ $ sudo apt install -y code Reading package lists... Done Building dependency tree... Done Reading state information... Done code:arm64 is already the newest version (1.86.2-1707853305). You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: code:arm64 : Depends: libasound2:arm64 (>= 1.0.17) but it is not installable Depends: libatk-bridge2.0-0:arm64 (>= 2.5.3) but it is not installable Depends: libatk1.0-0:arm64 (>= 2.2.0) but it is not installable Depends: libatspi2.0-0:arm64 (>= 2.9.90) but it is not installable Depends: libc6:arm64 (>= 2.17) but it is not installable Depends: libc6:arm64 (>= 2.28) but it is not installable Depends: libcairo2:arm64 (>= 1.6.0) but it is not installable Depends: libcurl3-gnutls:arm64 but it is not installable or libcurl3-nss:arm64 but it is not installable or libcurl4:arm64 but it is not installable or libcurl3:arm64 but it is not installable Depends: libdbus-1-3:arm64 (>= 1.9.14) but it is not installable Depends: libdrm2:arm64 (>= 2.4.75) but it is not installable Depends: libexpat1:arm64 (>= 2.1~beta3) but it is not installable Depends: libgbm1:arm64 (>= 17.1.0~rc2) but it is not installable Depends: libglib2.0-0:arm64 (>= 2.37.3) but it is not installable Depends: libgssapi-krb5-2:arm64 (>= 1.17) but it is not installable Depends: libgtk-3-0:arm64 (>= 3.9.10) but it is not installable Depends: libgtk-3-0:arm64 (>= 3.9.10) but it is not installable or libgtk-4-1:arm64 but it is not installable Depends: libkrb5-3:arm64 (>= 1.6.dfsg.2) but it is not installable Depends: libnspr4:arm64 (>= 2:4.9-2~) but it is not installable Depends: libnss3:arm64 (>= 2:3.30) but it is not installable Depends: libnss3:arm64 (>= 3.26) but it is not installable Depends: libpango-1.0-0:arm64 (>= 1.14.0) but it is not installable Depends: libstdc++6:arm64 (>= 4.1.1) but it is not installable Depends: libstdc++6:arm64 (>= 5) but it is not installable Depends: libstdc++6:arm64 (>= 5.2) but it is not installable Depends: libstdc++6:arm64 (>= 6) but it is not installable Depends: libx11-6:arm64 but it is not installable Depends: libx11-6:arm64 (>= 2:1.4.99.1) but it is not installable Depends: libxcb1:arm64 (>= 1.9.2) but it is not installable Depends: libxcomposite1:arm64 (>= 1:0.4.4-1) but it is not installable Depends: libxdamage1:arm64 (>= 1:1.1) but it is not installable Depends: libxext6:arm64 but it is not installable Depends: libxfixes3:arm64 but it is not installable Depends: libxkbcommon0:arm64 (>= 0.5.0) but it is not installable Depends: libxkbfile1:arm64 (>= 1:1.1.0) but it is not installable Depends: libxrandr2:arm64 but it is not installable Recommends: libvulkan1:arm64 but it is not installable E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
最新发布
07-18
import torch import numpy as np from matplotlib import pyplot as plt from torch.utils.data import DataLoader from torchvision import transforms from torchvision import datasets import torch.nn.functional as F “”" 卷积运算 使用mnist数据集,和10-4,11类似的,只是这里:1.输出训练轮的acc 2.模型上使用torch.nn.Sequential “”" Super parameter ------------------------------------------------------------------------------------ batch_size = 64 learning_rate = 0.01 momentum = 0.5 EPOCH = 10 Prepare dataset ------------------------------------------------------------------------------------ transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]) softmax归一化指数函数(https://blog.csdn.net/lz_peter/article/details/84574716),其中0.1307是mean均值和0.3081是std标准差 train_dataset = datasets.MNIST(root=‘./data/mnist’, train=True, transform=transform) # 本地没有就加上download=True test_dataset = datasets.MNIST(root=‘./data/mnist’, train=False, transform=transform) # train=True训练集,=False测试集 train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True) test_loader = DataLoader(test_dataset, batch_size=batch_size, shuffle=False) fig = plt.figure() for i in range(12): plt.subplot(3, 4, i+1) plt.tight_layout() plt.imshow(train_dataset.train_data[i], cmap=‘gray’, interpolation=‘none’) plt.title(“Labels: {}”.format(train_dataset.train_labels[i])) plt.xticks([]) plt.yticks([]) plt.show() 训练集乱序,测试集有序 Design model using class ------------------------------------------------------------------------------ class Net(torch.nn.Module): def init(self): super(Net, self).init() self.conv1 = torch.nn.Sequential( torch.nn.Conv2d(1, 10, kernel_size=5), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel_size=2), ) self.conv2 = torch.nn.Sequential( torch.nn.Conv2d(10, 20, kernel_size=5), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel_size=2), ) self.fc = torch.nn.Sequential( torch.nn.Linear(320, 50), torch.nn.Linear(50, 10), ) def forward(self, x): batch_size = x.size(0) x = self.conv1(x) # 一层卷积层,一层池化层,一层激活层(图是先卷积后激活再池化,差别不大) x = self.conv2(x) # 再来一次 x = x.view(batch_size, -1) # flatten 变成全连接网络需要的输入 (batch, 20,4,4) ==> (batch,320), -1 此处自动算出的是320 x = self.fc(x) return x # 最后输出的是维度为10的,也就是(对应数学符号的0~9) model = Net() Construct loss and optimizer ------------------------------------------------------------------------------ criterion = torch.nn.CrossEntropyLoss() # 交叉熵损失 optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate, momentum=momentum) # lr学习率,momentum冲量 Train and Test CLASS -------------------------------------------------------------------------------------- 把单独的一轮一环封装在函数类里 def train(epoch): running_loss = 0.0 # 这整个epoch的loss清零 running_total = 0 running_correct = 0 for batch_idx, data in enumerate(train_loader, 0): inputs, target = data optimizer.zero_grad() # forward + backward + update outputs = model(inputs) loss = criterion(outputs, target) loss.backward() optimizer.step() # 把运行中的loss累加起来,为了下面300次一除 running_loss += loss.item() # 把运行中的准确率acc算出来 _, predicted = torch.max(outputs.data, dim=1) running_total += inputs.shape[0] running_correct += (predicted == target).sum().item() if batch_idx % 300 == 299: # 不想要每一次都出loss,浪费时间,选择每300次出一个平均损失,和准确率 print('[%d, %5d]: loss: %.3f , acc: %.2f %%' % (epoch + 1, batch_idx + 1, running_loss / 300, 100 * running_correct / running_total)) running_loss = 0.0 # 这小批300的loss清零 running_total = 0 running_correct = 0 # 这小批300的acc清零 #保存模型 torch.save(model.state_dict(), ‘./model_Mnist.pth’) torch.save(optimizer.state_dict(), ‘./optimizer_Mnist.pth’) def test(): correct = 0 total = 0 with torch.no_grad(): # 测试集不用算梯度 for data in test_loader: images, labels = data outputs = model(images) _, predicted = torch.max(outputs.data, dim=1) # dim = 1 列是第0个维度,行是第1个维度,沿着行(第1个维度)去找1.最大值和2.最大值的下标 total += labels.size(0) # 张量之间的比较运算 correct += (predicted == labels).sum().item() acc = correct / total print('[%d / %d]: Accuracy on test set: %.1f %% ’ % (epoch+1, EPOCH, 100 * acc)) # 求测试的准确率,正确数/总数 return acc Start train and Test -------------------------------------------------------------------------------------- if name == ‘main’: acc_list_test = [] for epoch in range(EPOCH): train(epoch) # if epoch % 10 == 9: #每训练10轮 测试1次 acc_test = test() acc_list_test.append(acc_test) plt.plot(acc_list_test) plt.xlabel('Epoch') plt.ylabel('Accuracy On TestSet') plt.show() 在原始训练代码文件末尾追加以下内容(确保Net类已定义) import torch import onnx import onnxruntime as ort 模型定义必须与训练时完全一致(此处直接使用原文件中的Net类) class Net(torch.nn.Module): def init(self): super(Net, self).init() self.conv1 = torch.nn.Sequential( torch.nn.Conv2d(1, 10, kernel_size=5), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel_size=2), ) self.conv2 = torch.nn.Sequential( torch.nn.Conv2d(10, 20, kernel_size=5), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel_size=2), ) self.fc = torch.nn.Sequential( torch.nn.Linear(320, 50), torch.nn.Linear(50, 10), ) def forward(self, x): batch_size = x.size(0) x = self.conv1(x) x = self.conv2(x) x = x.view(batch_size, -1) x = self.fc(x) return x 导出配置 ------------------------------------------------------------------ PTH_PATH = ‘./model_Mnist.pth’ ONNX_PATH = ‘./model_Mnist.onnx’ 初始化并加载模型 model = Net() model.load_state_dict(torch.load(PTH_PATH)) model.eval() 创建符合MNIST输入的虚拟数据(1,1,28,28) dummy_input = torch.randn(1, 1, 28, 28) 执行导出 torch.onnx.export( model, dummy_input, ONNX_PATH, input_names=[“input”], output_names=[“output”], opset_version=13, dynamic_axes={ ‘input’: {0: ‘batch_size’}, ‘output’: {0: ‘batch_size’} } ) 验证导出结果 ------------------------------------------------------------- def validate_onnx(): # 加载ONNX模型 onnx_model = onnx.load(ONNX_PATH) onnx.checker.check_model(onnx_model) # 对比原始模型与ONNX模型输出 with torch.no_grad(): torch_out = model(dummy_input) ort_session = ort.InferenceSession(ONNX_PATH) onnx_out = ort_session.run( None, {'input': dummy_input.numpy()} )[0] # 输出相似度验证 print(f"PyTorch输出: {torch_out.numpy()}") print(f"ONNX输出: {onnx_out}") print(f"最大差值: {np.max(np.abs(torch_out.numpy() - onnx_out))}") validate_onnx() 这是我的手写体识别代码,生成了onnx文件,现在我想在Ubuntu上将onnx转化为rknn模型,请基于下面的代码结构与内容,生成适配我的源码的转化rknn代码,且注意,下面代码的rknn-toolkit2版本是2.3.0,但我的Ubuntu安装的是1.6.0版本的按照这些要求来生成需要的正确的代码 if __name__ == '__main__': # Create RKNN object rknn = RKNN(verbose=True) if not os.path.exists(ONNX_MODEL): print('Dosent exists ONNX_MODEL') # pre-process config print('--> config model') rknn.config(mean_values=None, std_values=None, target_platform='rk3588') print('done') # Load model print('--> Loading model') ret = rknn.load_onnx(model=ONNX_MODEL) if ret != 0: print('Load model failed!') exit(ret) print('done') # Build model print('--> Building model') ret = rknn.build(do_quantization=False) # No quantization if ret != 0: print('Build model failed!') exit(ret) print('done') # Export rknn model print('--> Export rknn model') ret = rknn.export_rknn(RKNN_MODEL) if ret != 0: print('Export rknn model failed!') exit(ret) print('done') # Init runtime environment print('--> Init runtime environment') ret = rknn.init_runtime() # target = 'rk3588' if ret != 0: print('Init runtime environment failed!') exit(ret) print('done') # Inference print('--> Running model')
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值