I cannot directly use either of the following statements
import android.util.Log;
or
import android.os.Environment;
from InetAddress.java in libcore/luni/src/main/java/java/net, nor can I use any file which depends on it. A member of a group that I am working with has created a class which depends on android.os.Environment and has used it successfully in other places in AOSP such as packages/apps/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
I'm not 100% certain there are not alternative methods to accomplish the tasks that the class he created is intended to accomplish, but for purposes of consistency I'd prefer to re-use his code in InetAddress.java if at all possible.
The error messages I receive are
Error: no package named android.os
Error: no package named android.util
I found this resource after searching for solutions on Google which suggested removing these lines to be able to import from standard libraries LOCAL_NO_STANDARD_LIBRARY = true;
Following this advice, I searched for parent directory closest to InetAddress.java which has an Android.mk file and tried editing it, saw that it had no lines that said LOCAL_NO_STANDARD_LIBRARY = true;
but it did call JavaLibrary.mk which did contain those lines. After commenting them out and rebuilding, the following lines appeared in the output after running make:
make: Circular out/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar dependency dropped.
make: Circular out/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar dependency dropped.
make: Circular out/target/common/obj/JAVA_LIBRARIES/framework-base_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar dependency dropped.
make: Circular out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar dependency dropped.
make: Circular out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar dependency dropped.
make: *** [out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes-full-debug.jar] Error 41
make: *** Waiting for unfinished jobs....
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
make: *** [out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-full-debug.jar] Error 41
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
make: *** [out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-full-debug.jar] Error 41
I can post the full make output if it's necessary, but these lines are the only lines that seem to not be part of the normal output of the build process.
Answers or comments which provide alternatives to using android.os in the first place are certainly appreciated as that is the fallback, but I'd prefer to get these imports working if at all possible.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…