Compiling android apps on an actual phone

2020-05-19 09:09发布

问题:

Hi I'd like to know how to compile an app source code on an android platform? I know it's possible because I saw some apps that are doing it... Thanx ahead!

回答1:

I think what you are asking for is a way to compile android apps on an android device.

the way an app like this new IDE does.

If so what you would need to do is to take an open source java compiler such as the ejc (the Java compiler used within Eclipse) and use it to compile your java source. You would then need to port the dalvik compiler to be able to run, in order to generate dex from the class files generated by the java compiler.

An interview with he developers of AIDE has a little bit more info on how they did it.

UPDATE:

Actually I just came across an open source project which provides similar functionality but based on using vim and the existing SDK cli tools ported to run on a an android device. The project is hosted here.

UPDATE 2:

I found yet another open source project that also does on device compile/build which I think should provide you with examples of what you are trying to do...

More specifically, if you look in IDE.java, you can see how the individual tools (ejc, dx, aapt) are called/used.



回答2:

Possible in a number of ways...

There have been apps - proprietary & open source - built for the purpose. I am not sure if these apps will be at least near the production quality. But they work:

It mainly depends on language you are writing - since cross platform app development is also possible on Android.

• Java: Java N-IDE, AIDE

• JavaScript: NativeScript CLI, Appcelerator Titanium CLI, Apache Cordova via CLI. [All these can be installed via node.js package manager (npm) which in turn can be installed via Dory NodeJS, GNURoot Debian or Termux apps..

• Linux CLI utilities can be installed on Android simply with a terminal shell or GNURoot / Termux. You can also Emulate complete PC OS using Limbo PC Emulator / Bochs [Although they should be lightweight]. In theory, by this way you should be able to use almost all Android development utilities. But Storage, memory & performance constraints come to play..

• There are other apps & web services for hobbyists: eg: Sketchware, DroidScript, Appy Pie, Monaca, PhoneGap Build and many others.... But don't expect professional quality apps using them..