Skip to content

Instantly share code, notes, and snippets.

@ricardoleme
Created April 26, 2023 13:06
Show Gist options
  • Select an option

  • Save ricardoleme/6fef4b2a32df9d33c3d7b91046ff9d17 to your computer and use it in GitHub Desktop.

Select an option

Save ricardoleme/6fef4b2a32df9d33c3d7b91046ff9d17 to your computer and use it in GitHub Desktop.
Gerando APK local com o novo EAS do Expo

Para gerar um APK local com o novo EAS do Expo:

  1. Instale o eas-cli de forma Global via npm (o Expo nΓ£o recomenda o uso do Yarn para pacotes globaisπŸ˜ͺ)
npm install -g eas-cli
  1. FaΓ§a o login na sua conta Expo
eas login
  1. Gere o arquivo de configuraΓ§Γ£o (eas.json)
eas build:configure
  1. Substitua o arquivo gerado pelo conteΓΊdo abaixo:
{
  "build": {
    "preview": {
      "android": {
        "buildType": "apk"
      }
    },
    "preview2": {
      "android": {
        "gradleCommand": ":app:assembleRelease"
      }
    },
    "preview3": {
      "developmentClient": true
    },
    "production": {}
  }
}
  1. Gere o APK
eas build -p android --profile preview
  1. Caso faΓ§a alguma alteraΓ§Γ£o no cΓ³digo fonte, basta repetir o passo 5 para gerar novamente a APK.
@gabrilh804-netizenh
Copy link

/
β”œβ”€ app/
β”‚ β”œβ”€ src/
β”‚ β”‚ β”œβ”€ main/
β”‚ β”‚ β”‚ β”œβ”€ java/com/kali/ai/MainActivity.java
β”‚ β”‚ β”‚ β”œβ”€ res/layout/activity_main.xml
β”‚ β”‚ β”‚ β”œβ”€ AndroidManifest.xml
β”‚ β”‚ β”‚ └─ assets/kali/index.htmlpackage com.kali.ai;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import java.util.Locale;

public class MainActivity extends AppCompatActivity {

private WebView webView;
private TextToSpeech tts;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = findViewById(R.id.webview);

    WebSettings ws = webView.getSettings();
    ws.setJavaScriptEnabled(true);
    ws.setDomStorageEnabled(true);
    ws.setAllowFileAccess(true);
    ws.setAllowContentAccess(true);

    webView.setWebChromeClient(new WebChromeClient());
    webView.loadUrl("file:///android_asset/kali/index.html");

    pedirPermissaoMicrofone();

    tts = new TextToSpeech(this, status -> {
        if (status == TextToSpeech.SUCCESS) {
            tts.setLanguage(new Locale("pt","BR"));
        }
    });
}

private void pedirPermissaoMicrofone() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
            != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.RECORD_AUDIO}, 200);
    }
}

public void falarTexto(String texto){
    tts.speak(texto, TextToSpeech.QUEUE_FLUSH, null, null);
}

@Override
protected void onDestroy() {
    if (tts != null){
        tts.stop();
        tts.shutdown();
    }
    super.onDestroy();
}

}

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<application
    android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
    android:label="KALI IA">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

<title>KALI IA</title> <style> body { background-color: #080014; color: #C9AFFF; font-family: Arial; } #caixa { width: 90%; height: 70vh; margin: auto; overflow-y: scroll; border: 1px solid #6611FF; padding: 10px; border-radius: 12px; box-shadow: 0px 0px 20px #6611FF; } #entrada { width: 90%; margin: auto; margin-top: 20px; } input { width: 80%; padding: 15px; border-radius: 10px; background-color: #1F0033; border: 1px solid #6611FF; color: #fff; font-size: 18px; } button { padding: 15px; border: none; background-color: #6611FF; color: white; border-radius: 10px; font-size: 16px; } </style>

πŸ”₯ KALI IA β€” Sistema Inteligente Completo πŸ”₯

Enviar
<script> function enviar() { let msg = document.getElementById("msg").value; if(msg.trim() === "") return; let caixa = document.getElementById("caixa"); caixa.innerHTML += "

VocΓͺ: " + msg + "

"; fetch("https://api.openai.com/v1/chat/completions", { method:"POST", headers:{ "Content-Type":"application/json", "Authorization":"Bearer SUA_CHAVE_AQUI" }, body:JSON.stringify({ model:"gpt-5.1", messages:[{role:"user",content:msg}] }) }) .then(r=>r.json()) .then(d=>{ let resposta = d.choices[0].message.content; caixa.innerHTML += "

KALI IA: " + resposta + "

"; }); } </script>

@gabrilh804-netizenh
Copy link

/ β”œβ”€ app/ β”‚ β”œβ”€ src/ β”‚ β”‚ β”œβ”€ main/ β”‚ β”‚ β”‚ β”œβ”€ java/com/kali/ai/MainActivity.java β”‚ β”‚ β”‚ β”œβ”€ res/layout/activity_main.xml β”‚ β”‚ β”‚ β”œβ”€ AndroidManifest.xml β”‚ β”‚ β”‚ └─ assets/kali/index.htmlpackage com.kali.ai;

import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView;

import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat;

import java.util.Locale;

public class MainActivity extends AppCompatActivity {

private WebView webView;
private TextToSpeech tts;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = findViewById(R.id.webview);

    WebSettings ws = webView.getSettings();
    ws.setJavaScriptEnabled(true);
    ws.setDomStorageEnabled(true);
    ws.setAllowFileAccess(true);
    ws.setAllowContentAccess(true);

    webView.setWebChromeClient(new WebChromeClient());
    webView.loadUrl("file:///android_asset/kali/index.html");

    pedirPermissaoMicrofone();

    tts = new TextToSpeech(this, status -> {
        if (status == TextToSpeech.SUCCESS) {
            tts.setLanguage(new Locale("pt","BR"));
        }
    });
}

private void pedirPermissaoMicrofone() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
            != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.RECORD_AUDIO}, 200);
    }
}

public void falarTexto(String texto){
    tts.speak(texto, TextToSpeech.QUEUE_FLUSH, null, null);
}

@Override
protected void onDestroy() {
    if (tts != null){
        tts.stop();
        tts.shutdown();
    }
    super.onDestroy();
}

}

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<application
    android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
    android:label="KALI IA">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
<title>KALI IA</title> <style> body { background-color: #080014; color: #C9AFFF; font-family: Arial; } #caixa { width: 90%; height: 70vh; margin: auto; overflow-y: scroll; border: 1px solid #6611FF; padding: 10px; border-radius: 12px; box-shadow: 0px 0px 20px #6611FF; } #entrada { width: 90%; margin: auto; margin-top: 20px; } input { width: 80%; padding: 15px; border-radius: 10px; background-color: #1F0033; border: 1px solid #6611FF; color: #fff; font-size: 18px; } button { padding: 15px; border: none; background-color: #6611FF; color: white; border-radius: 10px; font-size: 16px; } </style> ## πŸ”₯ KALI IA β€” Sistema Inteligente Completo πŸ”₯ Enviar <script> function enviar() { let msg = document.getElementById("msg").value; if(msg.trim() === "") return; let caixa = document.getElementById("caixa"); caixa.innerHTML += " VocΓͺ: " + msg + "

"; fetch("https://api.openai.com/v1/chat/completions", { method:"POST", headers:{ "Content-Type":"application/json", "Authorization":"Bearer SUA_CHAVE_AQUI" }, body:JSON.stringify({ model:"gpt-5.1", messages:[{role:"user",content:msg}] }) }) .then(r=>r.json()) .then(d=>{ let resposta = d.choices[0].message.content; caixa.innerHTML += "
KALI IA: " + resposta + "

"; }); } </script>

@gabrilh804-netizenh
Copy link

/ β”œβ”€ app/ β”‚ β”œβ”€ src/ β”‚ β”‚ β”œβ”€ main/ β”‚ β”‚ β”‚ β”œβ”€ java/com/kali/ai/MainActivity.java β”‚ β”‚ β”‚ β”œβ”€ res/layout/activity_main.xml β”‚ β”‚ β”‚ β”œβ”€ AndroidManifest.xml β”‚ β”‚ β”‚ └─ assets/kali/index.htmlpackage com.kali.ai;
import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView;
import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {

private WebView webView;
private TextToSpeech tts;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = findViewById(R.id.webview);

    WebSettings ws = webView.getSettings();
    ws.setJavaScriptEnabled(true);
    ws.setDomStorageEnabled(true);
    ws.setAllowFileAccess(true);
    ws.setAllowContentAccess(true);

    webView.setWebChromeClient(new WebChromeClient());
    webView.loadUrl("file:///android_asset/kali/index.html");

    pedirPermissaoMicrofone();

    tts = new TextToSpeech(this, status -> {
        if (status == TextToSpeech.SUCCESS) {
            tts.setLanguage(new Locale("pt","BR"));
        }
    });
}

private void pedirPermissaoMicrofone() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
            != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.RECORD_AUDIO}, 200);
    }
}

public void falarTexto(String texto){
    tts.speak(texto, TextToSpeech.QUEUE_FLUSH, null, null);
}

@Override
protected void onDestroy() {
    if (tts != null){
        tts.stop();
        tts.shutdown();
    }
    super.onDestroy();
}

}

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<application
    android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
    android:label="KALI IA">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
<title>KALI IA</title> <style> body { background-color: #080014; color: #C9AFFF; font-family: Arial; } #caixa { width: 90%; height: 70vh; margin: auto; overflow-y: scroll; border: 1px solid #6611FF; padding: 10px; border-radius: 12px; box-shadow: 0px 0px 20px #6611FF; } #entrada { width: 90%; margin: auto; margin-top: 20px; } input { width: 80%; padding: 15px; border-radius: 10px; background-color: #1F0033; border: 1px solid #6611FF; color: #fff; font-size: 18px; } button { padding: 15px; border: none; background-color: #6611FF; color: white; border-radius: 10px; font-size: 16px; } </style> ## πŸ”₯ KALI IA β€” Sistema Inteligente Completo πŸ”₯ Enviar <script> function enviar() { let msg = document.getElementById("msg").value; if(msg.trim() === "") return; let caixa = document.getElementById("caixa"); caixa.innerHTML += " VocΓͺ: " + msg + " "; fetch("https://api.openai.com/v1/chat/completions", { method:"POST", headers:{ "Content-Type":"application/json", "Authorization":"Bearer SUA_CHAVE_AQUI" }, body:JSON.stringify({ model:"gpt-5.1", messages:[{role:"user",content:msg}] }) }) .then(r=>r.json()) .then(d=>{ let resposta = d.choices[0].message.content; caixa.innerHTML += " KALI IA: " + resposta + " "; }); } </script>

Uploading Screenshot_20251205-163305.jpg…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment