Skip to content

Instantly share code, notes, and snippets.

@tmatz
Last active March 10, 2021 13:17
Show Gist options
  • Save tmatz/cafecc5759911fcefc3ba8d347b06a48 to your computer and use it in GitHub Desktop.
Save tmatz/cafecc5759911fcefc3ba8d347b06a48 to your computer and use it in GitHub Desktop.
Develop application using AIDE and install from Linux on Chromebook(arm64)

Develop Android application on Chromebook(arm64)

  • Build android application using AIDE on Android.
  • Launch 'Install APK' app whick is in Linux folder on desktop.

Setup

  • Enable ADB Debug of Linux.
  • Copy install-apk file into /usr/local/bin/, and exec sudo chmod +x /usr/local/bin/install-apk.
  • Copy install-apk.desktop file into /usr/shere/applications/, and exec sudo update-desktop-database.
#!/usr/bin/env python3
import subprocess
import sys
import os.path
import tkinter as tk
apk = '/mnt/sdcard/Android/data/com.aide.ui/cache/apk/app.apk'
if len(sys.argv) >= 2:
apk = sys.argv[1]
def pull_apk(fromPath, toPath):
p = subprocess.Popen(
['adb', 'pull', fromPath, toPath],
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT)
while p.poll() is None:
text.insert(tk.END, p.stdout.readline().decode())
root.update()
def install_apk(apk):
tmpApk = '/tmp/app.apk'
if not os.path.isfile(apk):
text.insert(tk.END, f"Now pulling ...\n")
pull_apk(apk, tmpApk)
apk = tmpApk
text.insert(tk.END, f"Done\n")
text.insert(tk.END, f"Now installing ...\n")
btnExit['state'] = tk.DISABLED
btnInstall['state'] = tk.DISABLED
root.update()
p = subprocess.Popen(
['adb', 'install', apk],
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT)
while p.poll() is None:
text.insert(tk.END, p.stdout.readline().decode())
root.update()
btnExit['state'] = tk.NORMAL
def onClickInstall():
install_apk(apk)
root = tk.Tk()
root.title('Install APK')
text = tk.Text(root)
text.insert(tk.END, f"Press 'Install' Button to install {apk}.\n")
text.pack()
frame = tk.Frame(root)
frame.pack()
btnInstall = tk.Button(
frame,
text = 'Install',
command = onClickInstall)
btnInstall.pack(side=tk.LEFT)
btnExit = tk.Button(
frame,
text = 'Exit',
command = sys.exit)
btnExit.pack(side=tk.LEFT)
root.mainloop()
[Desktop Entry]
Type=Application
Icon=com.visualstudio.code
MimeType=application/vnd.android.package-archive;
Name=Install APK
Exec=/usr/local/bin/install-apk %F
Terminal=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment