@@ -230,7 +230,13 @@ runs:
230230 if : ${{ inputs.platform == 'android' && runner.os == 'Linux' }}
231231 run : |
232232 sudo apt-get update
233- sudo apt-get install -y libpulse0 libglu1-mesa
233+ sudo apt-get install -y \
234+ libpulse0 \
235+ libglu1-mesa \
236+ libnss3 \
237+ libxss1
238+
239+ echo "✅ Linux dependencies installed successfully"
234240 shell : bash
235241
236242 - name : Install Android SDK packages
@@ -245,10 +251,12 @@ runs:
245251 "platforms;android-${{ inputs.android-api-level }}" \
246252 "build-tools;34.0.0" \
247253 "emulator" \
248- "system-images;android-34 ;google_apis;${{ inputs.android-abi }}" \
254+ "system-images;android-${{ inputs.android-api-level }} ;google_apis;${{ inputs.android-abi }}" \
249255
250256 echo "Updating SDK packages..."
251257 "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --update
258+
259+ echo "✅ Android SDK packages installed successfully"
252260 shell : bash
253261
254262 # # NDK Setup
@@ -260,24 +268,6 @@ runs:
260268 echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
261269 shell : bash
262270
263- - name : Accept Android SDK licenses
264- if : ${{ inputs.platform == 'android' }}
265- run : |
266- echo "Accepting Android SDK licenses..."
267- bash -c 'yes | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --licenses' || true
268- shell : bash
269-
270- - name : Install Android SDK Packages
271- if : ${{ inputs.platform == 'android' }}
272- run : |
273- "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install \
274- "platform-tools" \
275- "platforms;android-${{ inputs.android-api-level }}" \
276- "build-tools;34.0.0" \
277- "emulator" \
278- "system-images;android-${{ inputs.android-api-level }};google_apis;${{ inputs.android-abi }}"
279- shell : bash
280-
281271 - name : Install Android NDK
282272 if : ${{ inputs.platform == 'android' }}
283273 run : |
@@ -295,21 +285,17 @@ runs:
295285 - name : Add NDK related toolchains to PATH
296286 if : ${{ inputs.platform == 'android' }}
297287 run : |
298- NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
288+ if [ "$RUNNER_OS" = "Linux" ]; then
289+ NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
290+ else
291+ NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/darwin-x86_64/bin"
292+ fi
299293 echo "$NDK_TOOLCHAIN" >> "$GITHUB_PATH"
300294 echo "$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}" >> "$GITHUB_PATH"
301295 shell : bash
302296
303297 # # Launch AVD
304298
305- - name : Install Android system image
306- if : ${{ inputs.platform == 'android' }}
307- run : |
308- IMAGE="system-images;android-${{ inputs.android-api-level }};google_apis;${{ inputs.android-abi }}"
309- echo "Installing system image: $IMAGE"
310- "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --install "$IMAGE"
311- shell : bash
312-
313299 - name : Set ANDROID_AVD_HOME for downstream steps
314300 if : ${{ inputs.platform == 'android'}}
315301 shell : bash
@@ -332,38 +318,73 @@ runs:
332318 - name : Launch Android Emulator
333319 if : ${{ inputs.platform == 'android' && inputs.setup-simulator == 'true' }}
334320 run : |
321+ # Linux with KVM hardware acceleration
335322 nohup "$ANDROID_HOME/emulator/emulator" \
336323 -avd "${{ inputs.android-avd-name }}" \
337324 -no-audio \
338325 -no-boot-anim \
339326 -no-window \
327+ -gpu swiftshader_indirect \
328+ -no-snapshot \
329+ -wipe-data \
330+ -accel on \
340331 -verbose > /dev/null 2>&1 &
341332 shell : bash
342333
343334 # # Wait for Emulator to Boot
344335 - name : Wait for Android Emulator to Boot
345336 if : ${{ inputs.platform == 'android' && inputs.setup-simulator == 'true' }}
346337 run : |
347- echo "Waiting for emulator to be ready..."
338+ echo "Waiting for emulator to be ready on $RUNNER_OS..."
339+
340+ # Wait for device to be detected by ADB
341+ echo "Waiting for ADB to detect device..."
348342 adb wait-for-device
349-
343+
344+ # Additional wait for emulator to stabilize
345+ sleep 10
346+
347+ # Check emulator status
348+ echo "Checking emulator processes..."
349+ if [ "$RUNNER_OS" = "Linux" ]; then
350+ ps aux | grep emulator || echo "No emulator processes found"
351+ fi
352+
353+ # Wait for boot to complete
350354 bootanim=""
351- timeout=300 # 5 minutes in seconds
355+ timeout=600 # 10 minutes for initial boot (Linux might be slower)
352356 elapsed=0
353357
354358 while [[ "$elapsed" -lt "$timeout" ]]; do
355359 bootanim=$(adb shell getprop init.svc.bootanim 2>/dev/null || echo "unknown")
356- echo "Waiting for emulator... ($bootanim) (${elapsed}s elapsed)"
360+ sys_boot_completed=$(adb shell getprop sys.boot_completed 2>/dev/null || echo "0")
361+
362+ echo "Waiting for emulator... bootanim: $bootanim, boot_completed: $sys_boot_completed (${elapsed}s elapsed)"
357363
358- if [[ "$bootanim" == *"stopped"* ]]; then
364+ if [[ "$bootanim" == *"stopped"* ]] && [[ "$sys_boot_completed" == "1" ]] ; then
359365 echo "✅ Emulator booted successfully"
366+
367+ # Unlock screen and disable animations for testing
368+ adb shell input keyevent 82 # Unlock
369+ adb shell settings put global window_animation_scale 0
370+ adb shell settings put global transition_animation_scale 0
371+ adb shell settings put global animator_duration_scale 0
372+
373+ echo "✅ Emulator is ready for testing"
360374 exit 0
361375 fi
362376
363- sleep 5
364- elapsed=$((elapsed + 5 ))
377+ sleep 10
378+ elapsed=$((elapsed + 10 ))
365379 done
366380
367381 echo "❌ Timeout waiting for emulator to boot"
382+
383+ # Debug information on failure
384+ echo "Debug: ADB devices:"
385+ adb devices
386+ echo "Debug: Emulator processes:"
387+ ps aux | grep emulator || echo "No emulator processes found"
388+
368389 exit 1
369- shell : bash
390+ shell : bash
0 commit comments