gpt4 book ai didi

java - 错误: package android. util不存在

转载 作者:太空宇宙 更新时间:2023-11-04 09:34:50 33 4
gpt4 key购买 nike

我正在尝试编译我的java代码,所以我首先将其转换为.class,然后转换为.dex,最后转换为smali,这一直有效,除了现在,因为我使用方法Log.e()而不是System.out.println()来记录一些错误;我无法将 .java 文件转换为 .class。

这是我启动以获取 .class 文件的命令:

$ javac helloworld.java

即使我已经导入了库import android.util.Log;
我收到以下错误:

sources/com/canal/android/external/CplusJni.java:9: error: package android.util does not exist import android.util.Log; ^

sources/com/canal/android/external/CplusJni.java:25: error: cannot find symbol

Log.e("-----------------------------------------------------------------------------");

^

symbol: variable Log

location: class CplusJni

sources/com/canal/android/external/CplusJni.java:26: error: cannot find symbol Log.e("cplusPKCS12Cert: ",cplusPKCS12Cert);

^

symbol: variable Log

location: class CplusJni

sources/com/canal/android/external/CplusJni.java:27: error: cannot find symbol

Log.e("-----------------------------------------------------------------------------");

^

symbol: variable Log

location: class CplusJni

sources/com/canal/android/external/CplusJni.java:35: error: cannot find symbol

Log.e("-----------------------------------------------------------------------------"); ^ symbol: variable Log

location: class CplusJni

sources/com/canal/android/external/CplusJni.java:36: error: cannot find symbol

Log.e("sSLSocketFactory: ",sSLSocketFactory);

^

symbol: variable Log

location: class CplusJni

sources/com/canal/android/external/CplusJni.java:37: error: cannot find symbol

Log.e("-----------------------------------------------------------------------------");

^

symbol: variable Log

location: class CplusJni

7 errors

这是我的代码:

package com.canal.android.external;

import java.io.ByteArrayInputStream;
import java.security.KeyStore;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import android.util.Log;`

public class CplusJni {
public static native byte[] getCplusPKCS12Cert();

public static native byte[] getCplusPKCS12Pass();

static {
System.loadLibrary("cplusnative");
}

public static SSLSocketFactory a() {
SSLSocketFactory sSLSocketFactory = null;
try {
SSLContext instance = SSLContext.getInstance("TLS");
byte[] cplusPKCS12Cert = getCplusPKCS12Cert();
Log.e("-----------------------------------------------------------------------------");
Log.e("cplusPKCS12Cert: ",cplusPKCS12Cert);
Log.e("-----------------------------------------------------------------------------");
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(cplusPKCS12Cert);
KeyStore instance2 = KeyStore.getInstance("PKCS12");
byteArrayInputStream.close();
KeyManagerFactory instance3 = KeyManagerFactory.getInstance("X509");
instance.init(instance3.getKeyManagers(), null, null);
HttpsURLConnection.setDefaultSSLSocketFactory(instance.getSocketFactory());
sSLSocketFactory = instance.getSocketFactory();
Log.e("-----------------------------------------------------------------------------");
Log.e("sSLSocketFactory: ",sSLSocketFactory);
Log.e("-----------------------------------------------------------------------------");
return sSLSocketFactory;
} catch (Exception unused) {
return sSLSocketFactory;
}
}
}

我希望得到一些帮助!

最佳答案

尝试这样解决

一步一步:

1- 打开自动导入设置

2- 关闭即时优化导入

3-删除排除列表中的类

关于java - 错误: package android. util不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56635359/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com