React_Native打包Android报错 uncompiled PNG file passed as argument. Must be compiled first into .flat...

打包Android 报错 提示 ....uncompiled PNG file passedasargument. Must be compiled first into .flat file..

解决办法:在android/gradle.properties 里添加 一行 android.enableAapt2 = false

如果打包出现类似drawable合并的问题:

....../android/app/build/intermediates/res/merged/release/drawable-hdpi-v4/node_modules_reactnavigationstack_dist_views_assets_backicon.png: error: Duplicate file

......./android/app/build/intermediates/res/merged/release/drawable-hdpi/node_modules_reactnavigationstack_dist_views_assets_backicon.png: Originalishere. The version qualifier may be implied.

FAILURE: Build failedwithan exception.

* What went wrong:

解决办法:

在这个目录下的文件node_modules/react-native/react.gradle :

在这方法里面 def currentBundleTask = tasks.create(...

在doFirst块之后) 添加以下代码到里面

doLast { 

 def moveFunc = { resSuffix -> 

     File originalDir = file("${resourcesDir}/drawable-${resSuffix}")

    if(originalDir.exists()) { 

        File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4") 

         ant.move(file: originalDir, tofile: destDir) 

     } } 

 moveFunc.curry("ldpi").call() 

 moveFunc.curry("mdpi").call() 

 moveFunc.curry("hdpi").call() 

 moveFunc.curry("xhdpi").call() 

 moveFunc.curry("xxhdpi").call() 

 moveFunc.curry("xxxhdpi").call()}

如下图:

打包Android 提示引入的node_modules中的第三方包

Failed to capture fingerprint of output files for task ':react-native-smart-amap-location:packageDebugResources' property 'incrementalFolder' during up-to-date check.> Could not read path 'D:\webSpaces\acgp-app-newOffice\node_modules\react-native-smart-amap-location\android\build\intermediates\incremental\packageDebugResources\merged.dir\values'.

解决办法: 

找到这个目录,直接删除 build 整个文件目录,并修改build.gradle中的compileSdkVersion与主工程中一致,重新编译打包

你可能感兴趣的:(React_Native打包Android报错 uncompiled PNG file passed as argument. Must be compiled first into .flat...)