-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Android apps from termux? #63
Comments
The busybox version of less does not handle required escape sequences used by 'git log', so require the complete less. See #63.
Yes, that would be great, will look at it more soon! The parts from NDK are already available, what's really missing is gradle support. Or perhaps lightweight build commands for building simple APK:s in Termux as an initial step.
Are you using an x86 device? Those packages are not as tested or used as arm packages are (where e.g. clang does not have this problem), but just report problems such as this and I will look into it!
This was due to the busybox version of less not supporting required escape sequences used by
Can you paste the exact message? I guess this is on a x86 device? |
Yes, something light without gradle is exactly what I'm looking for. I found this site that explains exactly what the Ant build scripts are doing, I'm reading it now. It should be possible to replace Ant/Gradle with make or your build command of choice and call all the necessary packaging tools, especially since you're already making available packaging utilities like aapt. As for the NDK compilers and other tools, those are patched a little for Android, whereas you are providing mostly stock versions. For example, these are all the changes they made to clang 3.6 from the NDK (every commit after "Merging r232389: by Joerg Sonnenberger"), less changes are similarly made to llvm (you can ignore all commits labeled [pndk], that's for some other tool). I don't know how much of a difference those changes will make, as I haven't examined them in detail, but they might matter.
No, stock Android 5.1.1 on ARM. I looked into this further and the issue appears to be that libgcc is shipped with your gcc package, which I didn't have installed. I see that the NDK clang also passes that flag: maybe it would be a good idea to provide libgcc and/or llvm's compiler-rt as separate packages for clang to use? After installing gcc, clang works fine.
Thanks, that fixed it.
ARM device, I got this output both when running gdb with a "hello world" test program and a larger binary I had built before:
|
Thanks for the information! Will look into the issues in the coming weeks! |
I'll spin off clang and gdb into their own issues, so that this issue is just about whether and how much the NDK/SDK tools will be made available to build Android apks natively on Android. |
Hmm, I see that you make available the new jack compiler, which apparently is now the default java bytecode/dex compiler when building Android 6.0, though not sure if it's become the default compiler in the latest app SDK too. Looks like you have most of the tools in place, just need to add the remaining pieces to sign and align apks and someone could write build scripts to do this. |
I'm experimenting with this a bit now. I see that
Any way you can provide an android.jar that can be used for this? |
The Otherwise you could try e.g. http://fornwall.net/android.jar which is the full android.jar from the android-21 platform in the SDK. |
Thanks for the jar files, tried them both. It turns out that both have an identical compressed So, it appears that all that is needed is the |
Great, perhaps an How do you specifiy the |
You pass any base packages to |
I just experimented with building a simple sample app from the Android NDK, Here's what I did. First, I got the source for the NDK's sample apps: git clone https://github.com/googlesamples/android-ndk.git Then, I compiled the C and java source files for the cd android-ndk/hello-jni/app/src/main
clang -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -fno-integrated-as -target armv5te-none-linux-androideabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -O0 -UNDEBUG -marm -fno-omit-frame-pointer -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security -I/data/data/com.termux/files/usr/include -c jni/hello-jni.c -o ./hello-jni.o
mkdir -p lib/armeabi
clang -Wl,-soname,libhello-jni.so -shared ./hello-jni.o -lgcc -target armv5te-none-linux-androideabi -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm -o lib/armeabi/libhello-jni.so
jack java/ The I packaged up the apk using aapt package -M AndroidManifest.xml -S res -I /sdcard/Download/android.jar -F hello-jni.apk
aapt add ./hello-jni.apk classes.dex lib/armeabi/libhello-jni.so This unsigned apk could be used in an emulator, but I wanted to run the app on the same tablet on which I built it, so I signed it using the I copied over a cd META-INF/
openssl sha1 -binary ../lib/armeabi/libhello-jni.so | openssl base64
openssl sha1 -binary MANIFEST.MF | openssl base64
grep -A2 lib/armeabi/libhello-jni.so MANIFEST.MF| openssl sha1 -binary| openssl base64 The first openssl smime -sign -md sha1 -binary -noattr -in CERT.SF -out CERT.RSA -outform der -inkey ../privatekey.pem -signer ../apk.certificate
cd ..
aapt add ./hello-jni.apk META-INF/* Some info on generating a private key and certificate is here; I used the standard "Android Debug" owner/issuer info to create a debug certificate, as displayed in the second link above. After allowing installation of apps from unknown sources in the security section of my tablet's Settings, I'm able to run the resulting apk, that contains both native and Java code and built completely from scratch on the Termux command-line. Feel free to use the above info to put up a post or tutorial somewhere about what is possible with Termux, perhaps preceded with the full list of necessary Termux packages, as it might do well on reddit and other news sites and get you some publicity. No other mobile OS allows building apps directly on the mobile device itself, only Android with your Termux tools. It's a testament to the completely open-source toolchain google provides, the extreme openness and extensibility of Android, and your work repackaging all those tools to run on Android itself. All that remains for this issue is to provide the two files mentioned above that |
How to zipalign? |
zipalign is a separate executable that has not been made available yet. |
I'm having trouble building an android app with Termux. How do you install the Android SDK? When I run |
You have to copy android.jar from your sdk.
…On 25-Nov-2016 5:19 AM, "Billzabob" ***@***.***> wrote:
I'm having trouble building an android app with Termux. How do you install
the Android SDK? When I run jack java/ it can't find any of the Android
libraries. Is there a package for that?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMotBuNP2swhURtv3qw4BlBx9AUZq3R9ks5rBiKagaJpZM4GpbQd>
.
|
Are you missing usr/share/jack/android.jack? I think that's the file mine uses, unless I change the classpath or something. |
Thanks for the help. Both android.jar and android.jack work, although I guess neither include the support library. Interesting that jack doesn't use android.jack unless I tell it to use it. |
It should, all I have to run is |
Well it's working now. Not sure why it wasn't working before but at least it's fixed :) Thanks. |
I sometimes have weird issues if I forget to include one of the --output options. |
Where does the Dex file go if you doesn't specify an output directory for jack? |
I've never found any files from it outside of the tmp directory. Without the output format specified, I think it simply test compiles. I see it using three subdirectories of tmp, which are deleted when it's done. |
This comment was marked as spam.
This comment was marked as spam.
http://dl-ssl.google.com/android/repository/android_m2repository_r47.zip If it's outdated try increasing the number |
This comment was marked as spam.
This comment was marked as spam.
I resorted to forking the termux-app repo, removing the code coverage lines from the CI config, and adding code to upload the build artifacts from CI to my dropbox. I don't think that quite counts as building Termux from a smartphone though. Has any progress been made? |
I want to build android apps in termux but i can't able to make them please tell me how can i use termux for building android apps... |
What about ndk-build and ant |
I don't know |
also apktool doesn't work There's no option called --forced-package-id' |
aapt version old? |
sorry guys, I'm a newbie |
I have the following issue downloading termux-packages via git and executing the command ./scripts/setup-android-sdk.sh:
Any help is really apreciated! |
@jdnichollsc On which OS you are trying to install SDK ? In Termux it is not possible to use SDK/NDK. |
Hi @xeffyr, thanks for your quickly response |
@xeffyr what's the path of your termux-packages directory? |
As I wrote above, it is not possible to use Android SDK and NDK in Termux. Unless your device is x86_64 and you running a Linux chroot. Also, see https://github.com/termux/termux-packages/blob/master/build-package.sh#L12-L14. |
@xeffyr thanks mate for your help, one last question, what's the value of your ANDROID_HOME variable? |
It is unset. I don't need it as it is determined by script automatically. |
@xeffyr I'm having this issue |
@xeffyr sorry, my architecture is aarch64, so I can't use Android SDK :( |
Hi guys, @xeffyr can you confirm please? Thanks for your help, I want to share that solution! 👍 |
You can use the Android SDK and Android NDK on other architectures other than x86_64. Make two rootfs' of ubuntu, one of your architecture, the other x86_64. Proot into ubuntu of your arch, install Now x86_64 time! Install I might make some sort of repo to simplify this process. It's a lot of trial and error, an absolute mess. I built https://github.com/googlesamples/android-ndk/tree/master/native-activity on my phone: |
@Bakaika can you please create a guide or help me set this up? |
Wow, blown away, 405 packages available on Android. :)
Do you have any plans to package the necessary tools from the NDK and SDK so that I could write and build an Android apk directly from my tablet? I notice you have aapt packaged, which is used by the SDK to package apks. The compilers and linkers from the NDK wouldn't be hard, as it's all open source and you already build the stock versions yourself. I don't know how bad it would be to extract and build the necessary tools from the SDK. If that is your plan, that'd be great.
Some small bugs I've noticed so far:
-lgcc
to the linker, twice actually. If I compiled to an object file with clang and then ran the same linker command without that flag, it worked.git log
shows some cruft, specifically every commit starts like this:[[33mcommit a254fecc4824a884024e7907e2185cfc95e4c64d[[m
Ctrl-C
out of the program to get a backtrace in gdb. I ended up having to open another session and kill gdb.Love this work; if you have a bitcoin address, I suggest you make it public.
The text was updated successfully, but these errors were encountered: