安卓 java c,用javac编译android app

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.

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

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.

解决方案

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

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.

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

You can't, because:

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

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

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值