You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7最小化环境Jenkins构建Android APK遇Ninja启动失败求助

Hey there! Let's tackle your Android build issues on CentOS 7 Jenkins step by step—since you're new to Android dev, we'll keep this straightforward and actionable.

1. Fix the "No such file or directory" for Ninja (Direct Build Failure Cause)

Even though you installed Ninja, it's likely not in the PATH that Jenkins uses (system PATH and Jenkins runtime PATH can differ). Here's how to fix it:

  • First, find where Ninja is installed on your CentOS machine. Run this in a terminal:
    which ninja
    
    You'll get a path like /usr/local/bin/ninja or /opt/ninja/ninja.
  • Option 1: Add Ninja to Jenkins' global PATH
    Go to Jenkins → Manage Jenkins → Configure System → Global properties → Check "Environment variables" → Add a variable named PATH with value $PATH:/your/ninja/path (replace with the path from which ninja).
  • Option 2: Hardcode Ninja path in Gradle
    If you don't want to mess with Jenkins global config, add this to your app module's build.gradle under the android block:
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt" // Make sure this path matches your project's CMake file
            arguments "-DCMAKE_MAKE_PROGRAM=/your/ninja/path/ninja"
        }
    }
    

2. Resolve the ANDROID_NDK_DEPRECATED Warning

The warning tells you to replace the ANDROID_NDK_HOME environment variable with a direct version spec in Gradle. Do this in your app's build.gradle:

android {
    // Replace with your exact NDK r21 version (check SDK Manager for the full version string)
    ndkVersion "21.4.7075529"
    // Rest of your android config...
}

This makes Gradle use the exact NDK version you specify, no more relying on environment variables.

3. Address the 64-bit Library Requirement (Google Play Warning)

This is a warning, not an immediate build failure, but you'll need to fix it if you plan to publish to Google Play:

  • Update your app's build.gradle to include 64-bit ABIs:
    android {
        defaultConfig {
            externalNativeBuild {
                cmake {
                    abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
                }
            }
        }
    }
    
  • Double-check your CMakeLists.txt doesn't have any restrictions that block 64-bit targets (look for lines like SET(CMAKE_C_FLAGS "-m32") and remove them if present).

4. Fix the "Cannot execute CMake from NDK" Issue

Once you set ndkVersion in Gradle, this should resolve itself—Gradle will automatically locate the CMake bundled with your specified NDK version, so you won't get the "skipped" error anymore.

After applying these changes, try rerunning your Jenkins build. If you still hit issues, add --info to your Gradle build command in Jenkins to get more detailed logs!

内容的提问来源于stack exchange,提问作者Marko Barbančić

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 22:59:07