I am trying to compile my java code, so I first convert it to .class, then to .dex and finally to smali, this has always worked, except for now as I am using the method Log.e() instead of System.out.println() to log some errors; I am unable to convert the .java file to .class.
This is the command I launch to get the .class file:
$ javac helloworld.java
Even though I've imported the library import android.util.Log;
I get the following Error:
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
Here is my code:
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;
}
}
}
I would appreciate some help with this!