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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# ⚡ Comandos Rápidos - Android
## 🚀 Compilar e Instalar
```bash
# Exemplo simples (recomendado para primeiro teste)
.\build-android.ps1
# Exemplo completo
.\build-android.ps1 -example android_demo
# Jogo de tiro
.\build-android.ps1 -example mobile_shooter
# Demo avançado
.\build-android.ps1 -example android_advanced_demo
```
---
## 🔧 Comandos ADB Úteis
```bash
# Ver dispositivos conectados
adb devices
# Instalar APK
adb install -r caminho/para/app.apk
# Desinstalar app
adb uninstall com.sevenx.engine
# Ver logs
adb logcat | findstr "SevenX"
# Limpar logs
adb logcat -c
# Tirar screenshot
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png
# Gravar tela
adb shell screenrecord /sdcard/demo.mp4
# Ctrl+C para parar
adb pull /sdcard/demo.mp4
# Reiniciar ADB
adb kill-server
adb start-server
# Ver informações do dispositivo
adb shell getprop ro.product.model
adb shell getprop ro.build.version.release
# Ver uso de CPU/RAM do app
adb shell top | findstr "sevenx"
# Forçar parar app
adb shell am force-stop com.sevenx.engine
# Iniciar app
adb shell monkey -p com.sevenx.engine -c android.intent.category.LAUNCHER 1
# Limpar dados do app
adb shell pm clear com.sevenx.engine
```
---
## 📦 Compilação Manual
```bash
# Compilar apenas (sem instalar)
cargo apk build --example android_test --target aarch64-linux-android --release
# Compilar e instalar
cargo apk run --example android_test --target aarch64-linux-android --release
# Compilar em modo debug (mais rápido)
cargo apk build --example android_test --target aarch64-linux-android
# Compilar para ARMv7 (celulares antigos)
cargo apk build --example android_test --target armv7-linux-androideabi --release
# Compilar para x86_64 (emulador)
cargo apk build --example android_test --target x86_64-linux-android --release
```
---
## 🎯 Targets Android
```bash
# Adicionar targets
rustup target add aarch64-linux-android # ARM64 (moderno)
rustup target add armv7-linux-androideabi # ARMv7 (antigo)
rustup target add x86_64-linux-android # x86_64 (emulador)
rustup target add i686-linux-android # x86 (emulador antigo)
# Ver targets instalados
rustup target list --installed
# Remover target
rustup target remove aarch64-linux-android
```
---
## 🔍 Verificar Instalação
```bash
# Verificar Rust
cargo --version
rustc --version
# Verificar cargo-apk
cargo apk --version
# Verificar ADB
adb version
# Verificar NDK
dir "$env:ANDROID_NDK_HOME"
# Verificar SDK
dir "$env:ANDROID_HOME"
# Verificar variáveis de ambiente
echo $env:ANDROID_HOME
echo $env:ANDROID_NDK_HOME
```
---
## 🧹 Limpeza
```bash
# Limpar build
cargo clean
# Limpar apenas target Android
Remove-Item -Recurse -Force target/aarch64-linux-android
# Limpar cache do Cargo
cargo clean
Remove-Item -Recurse -Force ~/.cargo/registry/cache
# Desinstalar app do celular
adb uninstall com.sevenx.engine
```
---
## 📊 Informações do APK
```bash
# Ver informações do APK
aapt dump badging target/aarch64-linux-android/release/apk/examples/android_test.apk
# Ver tamanho do APK
(Get-Item target/aarch64-linux-android/release/apk/examples/android_test.apk).Length / 1MB
# Ver permissões do APK
aapt dump permissions target/aarch64-linux-android/release/apk/examples/android_test.apk
```
---
## 🐛 Debug
```bash
# Ver logs em tempo real
adb logcat
# Ver apenas erros
adb logcat *:E
# Ver logs do app
adb logcat | findstr "com.sevenx"
# Salvar logs em arquivo
adb logcat > logs.txt
# Ver crash logs
adb logcat | findstr "FATAL"
# Ver uso de memória
adb shell dumpsys meminfo com.sevenx.engine
# Ver uso de bateria
adb shell dumpsys batterystats com.sevenx.engine
```
---
## 🚀 Emulador
```bash
# Listar emuladores
emulator -list-avds
# Iniciar emulador
emulator -avd Pixel_6_API_33
# Iniciar emulador sem janela
emulator -avd Pixel_6_API_33 -no-window
# Iniciar emulador com GPU
emulator -avd Pixel_6_API_33 -gpu host
```
---
## 📱 Múltiplos Dispositivos
```bash
# Listar dispositivos
adb devices
# Instalar em dispositivo específico
adb -s DEVICE_ID install app.apk
# Ver logs de dispositivo específico
adb -s DEVICE_ID logcat
# Exemplo:
adb -s emulator-5554 install app.apk
```
---
## ⚙️ Configuração Avançada
```bash
# Aumentar velocidade de compilação
# Adicione ao .cargo/config.toml:
[build]
jobs = 8 # Número de cores do CPU
# Usar linker mais rápido (lld)
[target.aarch64-linux-android]
linker = "lld"
# Cache de compilação (sccache)
cargo install sccache
$env:RUSTC_WRAPPER = "sccache"
```
---
## 📋 Checklist Rápido
```bash
# Verificar tudo de uma vez
cargo --version && `
cargo apk --version && `
adb version && `
rustup target list --installed | findstr "android" && `
adb devices && `
echo "✅ Tudo OK!"
```
---
## 🎮 Exemplos Disponíveis
```bash
# Listar todos os exemplos
Get-ChildItem examples/*.rs | Select-Object Name
# Compilar todos os exemplos (demora!)
Get-ChildItem examples/*.rs | ForEach-Object {
$name = $_.BaseName
Write-Host "Building $name..."
cargo apk build --example $name --target aarch64-linux-android --release
}
```
---
## 💾 Backup do APK
```bash
# Copiar APK para pasta de backup
$date = Get-Date -Format "yyyy-MM-dd_HH-mm"
$apk = "target/aarch64-linux-android/release/apk/examples/android_test.apk"
Copy-Item $apk "backup/android_test_$date.apk"
```
---
## 🔄 Atualizar Ferramentas
```bash
# Atualizar Rust
rustup update
# Atualizar cargo-apk
cargo install cargo-apk --force
# Atualizar targets
rustup target add aarch64-linux-android --force
```
---
**Copie e cole os comandos que precisar! ⚡**