已解决:升级到Android Studio 3.1.2, 报错显示mips64el-linux-android-strip找不到

升级到Android Studio 3.1.2版本后,原有的NDK由r16升级到r17,因为 r17不再支持mips 导致ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/bin/mips64el-linux-android-strip 找不到, 导致编译报:Error:org.gradle.process.internal.ExecException: A problem occurred starting process 'command '...\ndk-bundle\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip''。

网上找到的解决办法是删掉NDK或者降级使用r16的NDK,这其实是治标不治本的,我的解决办法是在build.gradle脚本里排除mips:

android {
    defaultConfig {
        ndk {
            //支持的CPU架构,如armeabi、x86、mips等
            abiFilters "armeabi", "x86"
        }
    }
    packagingOptions {
        doNotStrip '*/mips/*.so'
        doNotStrip '*/mips64/*.so'
    }
}

参阅:https://stackoverflow.com/questions/42739916/aarch64-linux-android-strip-file-missing

I had the same problem using NDK version 17.0.4754217. You can workaround this issue by adding the following code in your gradle.build:

packagingOptions{
    doNotStrip '*/mips/*.so'
}
Or

packagingOptions{
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
}
If you are using native code (C++), I recommend add the following code too:

ndk {
    abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' // <- only the supported ones
}
To make sure you won't embed any MIPS binary.


猜你喜欢

转载自blog.csdn.net/waplyj/article/details/80604700