转载请注明文章出处:https://itlanyan.com/android-transfor…elease-exception/
打release包时出现transformNativeLibsWithStripDebugSymbolForRelease
异常:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForAppRelease'.
...
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'C:\Users\tlanyan\AppData\Local\Android\Sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip''
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:198)
at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:329)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:86)
... 5 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'C:\Users\tlanyan\AppData\Local\Android\Sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:68)
... 5 more
Caused by: java.io.IOException: Cannot run program "C:\Users\tlanyan\AppData\Local\Android\Sdk\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip" (in directory "E:\Demos\app\android\app"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 8 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 9 more
上网查教程,许多博客中说的升级gradle版本、修改sdk版本等未能解决问题。
卸载ndk是最后的选择,但不愿意为了一个项目作出这么大的牺牲。仔细看错误日志,发现情况和网上教程不同:网上教程解决的是NullException问题,而我是IoException。于是根据transformNativeLibsWithStripDebugSymbolForRelease
和no such file or directory
两个关键词再次上网搜索,终于在StackOverflow上找到解决办法:在build.gradle
配置中增加不trip项:
packagingOptions{
doNotStrip '*/mips/*.so'
}
新增配置后再次打包,问题解决。
Thank you so much for writing this helpful blog! Saved me lots of time 🙂