Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,16 @@ st.set_page_config(page_title="Android Build Server", layout="centered")
|
|
| 5 |
st.title("📱 Android APK Generator")
|
| 6 |
st.markdown("Flutter ya Native Android — dono projects ka APK banayega aur **Auto-Sign** karega.")
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def generate_keystore():
|
| 9 |
kp = "debug.keystore"
|
| 10 |
if not os.path.exists(kp):
|
|
@@ -42,6 +52,8 @@ f = st.file_uploader("Project ZIP Upload Karein", type=["zip"])
|
|
| 42 |
|
| 43 |
if f is not None:
|
| 44 |
if st.button("🔨 Create & Sign APK"):
|
|
|
|
|
|
|
| 45 |
sts = st.empty(); bar = st.progress(0)
|
| 46 |
if os.path.exists("project_extract"): shutil.rmtree("project_extract")
|
| 47 |
os.makedirs("project_extract")
|
|
|
|
| 5 |
st.title("📱 Android APK Generator")
|
| 6 |
st.markdown("Flutter ya Native Android — dono projects ka APK banayega aur **Auto-Sign** karega.")
|
| 7 |
|
| 8 |
+
def setup_java_env():
|
| 9 |
+
# Automatically detect valid JAVA_HOME path from system java binary
|
| 10 |
+
current_jh = os.environ.get("JAVA_HOME", "")
|
| 11 |
+
if not current_jh or not os.path.exists(os.path.join(current_jh, "bin", "java")):
|
| 12 |
+
java_bin = shutil.which("java")
|
| 13 |
+
if java_bin:
|
| 14 |
+
real_path = os.path.realpath(java_bin)
|
| 15 |
+
detected_jh = os.path.dirname(os.path.dirname(real_path))
|
| 16 |
+
os.environ["JAVA_HOME"] = detected_jh
|
| 17 |
+
|
| 18 |
def generate_keystore():
|
| 19 |
kp = "debug.keystore"
|
| 20 |
if not os.path.exists(kp):
|
|
|
|
| 52 |
|
| 53 |
if f is not None:
|
| 54 |
if st.button("🔨 Create & Sign APK"):
|
| 55 |
+
setup_java_env() # Auto detect and set JAVA_HOME
|
| 56 |
+
|
| 57 |
sts = st.empty(); bar = st.progress(0)
|
| 58 |
if os.path.exists("project_extract"): shutil.rmtree("project_extract")
|
| 59 |
os.makedirs("project_extract")
|