简体   繁体   English

'包不存在'使用javac转换.java class与谷歌播放服务导入

[英]'package does not exist' using javac to convert .java class with google play services imports

I have a.java class which uses imports from google play services.我有 a.java class,它使用从谷歌播放服务进口。 I want to put this class in a.jar to package with my project, but using javac filename.java in the terminal gives me a bunch of errors eg我想把这个 class 放在 a.jar 到 package 和我的项目中,但是在终端中使用javac filename.java给了我一堆错误,例如

androidSCAR.java:3: error: package android.content does not exist import android.content.Context;

How do I include these imports while creating a.class?在创建 a.class 时如何包含这些导入?

The.java file is in an android studio project which all works fine .java 文件位于 android 工作室项目中,一切正常

minimal example code:最小示例代码:

myClass.java file: myClass.java 文件:

import android.content.Context;

public class myClass
{

private static Context context;

}

Run javac myClass.java in terminal在终端运行javac myClass.java

Results:结果:

test.java:1: error: package android.content does not exist
import android.content.Context;
                      ^
test.java:6: error: cannot find symbol
private static Context context;
               ^
  symbol:   class Context
  location: class myClass

I found a work around - I built the android project using the.java class and grabbed the.class files from app\build\intermediates\javac\debug\classes\module-name , and used those to create my.jar file.我找到了解决方法——我使用 .java class 构建了 android 项目,并从app\build\intermediates\javac\debug\classes\module-name中获取了 .class 文件,并使用这些文件创建了 my.jar 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM