File size: 1,850 Bytes
5edc6a5
f3bc981
5edc6a5
f3bc981
5edc6a5
f3bc981
 
5edc6a5
f3bc981
 
 
 
 
 
5edc6a5
f3bc981
 
5edc6a5
f3bc981
 
5edc6a5
f3bc981
5edc6a5
 
f3bc981
5edc6a5
 
 
 
 
f3bc981
5edc6a5
 
f3bc981
 
5edc6a5
f3bc981
 
5edc6a5
 
f3bc981
 
5edc6a5
f3bc981
 
5edc6a5
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import subprocess
import gradio as gr

def build_android_app(app_name, package_name, website_url, app_logo):
    try:
        # Create a new Android app
        subprocess.check_call(["flutter", "create", app_name])
        
        # Configure the app
        with open(f"{app_name}/pubspec.yaml", "r+") as f:
            content = f.read()
            f.seek(0)
            f.write(content.replace("name: flutter_app", f"name: {app_name}").replace("description: A new Flutter project.", f"description: {website_url}").replace("# The following line ensures that the Material Icons font is\n  # included with your application, so that you can use the icons in\n  # the material Icons class.", f"  flutter:\n    assets:\n      - {app_logo}"))
            f.truncate()
        
        # Install dependencies
        subprocess.check_call(["flutter", "pub", "get"], cwd=app_name)
        
        # Run the app
        subprocess.check_call(["flutter", "run"], cwd=app_name)
        
        return "App built successfully."
    
    except Exception as e:
        return f"Error: {str(e)}"

# Gradio interface setup
demo = gr.Blocks()

with demo:
    gr.Markdown("## Android App Builder\nEnter your app details to build an Android app")
    
    with gr.Row():
        app_name = gr.Textbox(label="App Name")
        package_name = gr.Textbox(label="Package Name")
    
    website_url = gr.Textbox(label="Website URL")
    app_logo = gr.Textbox(label="App Logo")
    output = gr.Textbox(label="Output", placeholder="Output will appear here", lines=10)

    # Button to trigger app building
    build_button = gr.Button("Build App")
    
    # Bind the button to the function that builds the app
    build_button.click(fn=build_android_app, inputs=[app_name, package_name, website_url, app_logo], outputs=output)

# Launch the Gradio app
demo.launch()