用javac编译android app [英] compile android app with javac

查看:164
本文介绍了用javac编译android app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一部分Android应用程序正在尝试进行调整和测试. 因此,我取出了两个文件,并尝试使用javac编译器制作一个快速的可执行文件,以进行快速的测试-调整-重新测试. 我只想通过将其传递给单独的参数来测试这一部分代码.如果我可以javac编译它,然后运行测试,则可以更快地使用FAR.

I have a portion of an android app that I am trying to tweak and test. So I have pulled out two files and am trying to make a quick executable for quick test-tweak-retest turnarounds using the javac compiler. I just want to test this one section of code with handing it separate parameters. This would be FAR quicker to work with if I could just javac compile it and then run my tests.

但是我很难让javac编译器找到Android库.

But I'm having a hard time getting the javac compiler to find the Android libraries.

有人可以帮助我使用javac将这两个文件编译为一个可执行文件吗? 仅供参考,现在这两个文件实际上仅使用主要导入android.os.Environment;库.

Can anyone help me compile these two files into one executeable using javac? FYI right now these two files really only use the main import android.os.Environment; library.

感谢任何人可以提供的任何建议/帮助.

Thanks for any advice/help anyone can provide.

推荐答案

但是我很难让javac编译器找到Android库.

But I'm having a hard time getting the javac compiler to find the Android libraries.

那仍然无济于事. Android是一个操作系统.它不仅是少数的Java类.而且,android.jar文件中的Java类无论如何都不是真正的实现,只是对每个方法都抛出RuntimeException的存根.

That would not help you anyway. Android is an operating system. It is not just a handful of Java classes. And, the Java classes that are in the android.jar files are not real implementations anyway, merely stubs that just throw a RuntimeException on every method.

有人可以帮助我使用javac将这两个文件编译为一个可执行文件吗?

Can anyone help me compile these two files into one executeable using javac?

您不能这样做,因为:

这两个文件...使用... android.os.Environment

these two files... use... android.os.Environment

相反,请修改这些文件以删除其对Android类的依赖,因此它只是纯Java代码.

Instead, modify those files to remove their dependency upon Android classes, so it is just pure Java code.

或者,尝试 Robolectric 并使用它创建这两个类的单元测试.我不能保证您的代码能正常工作(我不知道Robolectric的模拟Environment对于您所调用的方法将返回什么),但是很有可能它会正常工作.

Or, try Robolectric and create a unit test of those two classes using it. I cannot guarantee that your code will work (I have no idea what Robolectric's mock Environment will return for the methods you are invoking), but there's a decent chance that it will work.

这篇关于用javac编译android app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆