Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,8 @@ def sign_apk(unsigned):
|
|
| 37 |
"--out",sg,target
|
| 38 |
], capture_output=True, text=True)
|
| 39 |
return sg if r.returncode == 0 else None
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
if f is not None:
|
| 43 |
if st.button("π¨ Create & Sign APK"):
|
|
@@ -59,10 +60,19 @@ if f is not None:
|
|
| 59 |
if flutter_root:
|
| 60 |
sts.info("π¦ Flutter project β flutter build apk chal raha hai...")
|
| 61 |
bar.progress(20)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
r1 = subprocess.run(["flutter","pub","get"], cwd=flutter_root, capture_output=True, text=True)
|
| 67 |
if r1.returncode != 0:
|
| 68 |
st.error("β flutter pub get fail!"); st.text(r1.stderr[-2000:])
|
|
@@ -82,6 +92,11 @@ if f is not None:
|
|
| 82 |
bar.progress(20)
|
| 83 |
with open(os.path.join(native_root,"local.properties"),"w") as lf:
|
| 84 |
lf.write(f"sdk.dir={os.environ.get('ANDROID_HOME','/opt/android-sdk')}\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
subprocess.run(["chmod","+x",os.path.join(native_root,"gradlew")])
|
| 86 |
bar.progress(25)
|
| 87 |
r = subprocess.run(["./gradlew","assembleRelease","--no-daemon","--stacktrace"],
|
|
|
|
| 37 |
"--out",sg,target
|
| 38 |
], capture_output=True, text=True)
|
| 39 |
return sg if r.returncode == 0 else None
|
| 40 |
+
|
| 41 |
+
f = st.file_uploader("Project ZIP Upload Karein", type=["zip"])
|
| 42 |
|
| 43 |
if f is not None:
|
| 44 |
if st.button("π¨ Create & Sign APK"):
|
|
|
|
| 60 |
if flutter_root:
|
| 61 |
sts.info("π¦ Flutter project β flutter build apk chal raha hai...")
|
| 62 |
bar.progress(20)
|
| 63 |
+
|
| 64 |
+
# Local properties setup
|
| 65 |
+
android_dir = os.path.join(flutter_root,"android")
|
| 66 |
+
if os.path.exists(android_dir):
|
| 67 |
+
with open(os.path.join(android_dir,"local.properties"),"w") as lf:
|
| 68 |
+
lf.write(f"sdk.dir={os.environ.get('ANDROID_HOME','/opt/android-sdk')}\n")
|
| 69 |
+
lf.write(f"flutter.sdk={os.environ.get('FLUTTER_HOME','/opt/flutter')}\n")
|
| 70 |
+
lf.write("flutter.buildMode=release\n")
|
| 71 |
+
|
| 72 |
+
# Limit gradle RAM for HF Free CPU space
|
| 73 |
+
with open(os.path.join(android_dir,"gradle.properties"),"a") as gp:
|
| 74 |
+
gp.write("\norg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m\n")
|
| 75 |
+
|
| 76 |
r1 = subprocess.run(["flutter","pub","get"], cwd=flutter_root, capture_output=True, text=True)
|
| 77 |
if r1.returncode != 0:
|
| 78 |
st.error("β flutter pub get fail!"); st.text(r1.stderr[-2000:])
|
|
|
|
| 92 |
bar.progress(20)
|
| 93 |
with open(os.path.join(native_root,"local.properties"),"w") as lf:
|
| 94 |
lf.write(f"sdk.dir={os.environ.get('ANDROID_HOME','/opt/android-sdk')}\n")
|
| 95 |
+
|
| 96 |
+
# Limit gradle RAM
|
| 97 |
+
with open(os.path.join(native_root,"gradle.properties"),"a") as gp:
|
| 98 |
+
gp.write("\norg.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m\n")
|
| 99 |
+
|
| 100 |
subprocess.run(["chmod","+x",os.path.join(native_root,"gradlew")])
|
| 101 |
bar.progress(25)
|
| 102 |
r = subprocess.run(["./gradlew","assembleRelease","--no-daemon","--stacktrace"],
|