反应本机错误:重复的资源,资产出现在某些屏幕中,而不出现在其他人的android版本APK中 [英] React Native Error: Duplicate resources, assets coming in some screens and not coming in others in android release APK

查看:58
本文介绍了反应本机错误:重复的资源,资产出现在某些屏幕中,而不出现在其他人的android版本APK中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Gradle版本3.2.0compileSdkVersion 28在Android中构建我的React Native应用的发行版APK.我正在运行以下命令:

I am building a release APK of my React Native app in Android using Gradle version 3.2.0 and compileSdkVersion 28. I am running the following commands:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew installRelease

我的文件夹结构是:

我的package.json是:

{
  "name": "App",
  "version": "2.0.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "native-base": "^2.8.0",
    "prop-types": "^15.6.2",
    "qs": "^6.5.2",
    "react": "^16.5.2",
    "react-native": "0.57.0",
    "react-native-animatable": "^1.3.0",
    "react-native-animated-icons": "^1.0.5",
    "react-native-appsee": "^2.4.14",
    "react-native-blur": "^3.2.2",
    "react-native-cast-chrome": "1.0.0",
    "react-native-cast-ui": "1.0.0",
    "react-native-device-info": "^0.22.3",
    "react-native-dialog": "^5.1.0",
    "react-native-elements": "^0.19.1",
    "react-native-email": "^1.0.1",
    "react-native-fast-image": "^5.0.3",
    "react-native-fbsdk": "^0.8.0",
    "react-native-flurry-analytics": "^3.0.2",
    "react-native-gridview": "^0.1.2",
    "react-native-iap": "^2.2.1",
    "react-native-iphone-x-helper": "^1.0.3",
    "react-native-keyboard-aware-scroll-view": "^0.7.0",
    "react-native-kochava-tracker": "^1.0.0",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-modal": "^6.5.0",
    "react-native-orientation": "^3.1.3",
    "react-native-photo-upload": "^1.3.0",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-snap-carousel": "^3.7.4",
    "react-native-tab-view": "^1.2.0",
    "react-native-underline-tabbar": "^1.3.6",
    "react-native-vector-icons": "^5.0.0",
    "react-native-video": "^3.2.1",
    "react-native-video-controls": "^2.2.3",
    "react-navigation": "^2.11.2",
    "react-navigation-backhandler": "^1.1.1",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/plugin-external-helpers": "^7.0.0",
    "ajv": "^6.5.2",
    "babel-eslint": "^9.0.0",
    "babel-jest": "23.4.2",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^5.3.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-react": "^7.11.0",
    "jest": "23.4.2",
    "metro-react-native-babel-preset": "^0.45.4",
    "react-test-renderer": "16.4.1",
    "schedule": "^0.4.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

在查看命令时,我的所有资产在Task :app:mergeReleaseResources FAILEDError: Duplicate resources上均显示错误.从我的可绘制文件夹中删除资产时,该应用程序会生成.

While ruuning the commands, I get error on Task :app:mergeReleaseResources FAILED with Error: Duplicate resources for all of my assets. When removing the assets from my drawable folders, the app builds.

但是在运行发行版APK时,有些图像根本不显示,而另一些则完全不显示.此外,同一图像出现在某些地方,而没有出现在其他地方.从JS服务器运行调试应用程序时,这些问题均不会发生.这个问题在iOS中不会发生.

But while running the release APK, some of the images are not appearing at all while others are. Furthermore, the same image is appearing in some places while not appearing in others. None of these problems happen while running the debug app from the JS server. This problem is not happening in iOS.

我该如何解决这个问题?

How do I solve this problem?

推荐答案

根据RN 0.57更改日志:

According to RN 0.57 change log:

Android工具已更新以匹配较新的配置 要求(SDK 27,gradle 4.4和支持库27);建筑 由于gradle脚本,Android插件3.2不能正常工作,因此 请暂时使用Android Studio 3.1

Android tooling has been updated to match newer configuration requirements (SDK 27, gradle 4.4, and support library 27); building with Android plugin 3.2 doesn't work due to the gradle scripts, so please stay on Android Studio 3.1 for now

1)尝试根据RN更改日志进行设置

1) try to set those according to RN change log

com.android.tools.build:gradle:3.1.4应该可以工作

2)尝试删除android build文件夹并仅运行./gradlew assembleRelease而不进行任何捆绑

2) try to remove android build folder and run just ./gradlew assembleRelease without any bundle-ing

我也使用RN 0.57,并且生成没有捆绑的apk对我来说很好.

I am using RN 0.57 too and generating apk without bundle-ing works ok for me.

如果您仍然有问题并想使用捆绑销售,请尝试检查:

If you still have problems and want to use bundle-ing try to check:

在生成apk时处理本机Android重复文件错误

从那里得到的这些答案应该可以解决问题:

These answers from there should fix the issue:

https://stackoverflow.com/a/52750886/1979861

https://stackoverflow.com/a/50876742/1979861

此处有关于0.57 android更新的更多信息:

More info about 0.57 android updates here:

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md

这篇关于反应本机错误:重复的资源,资产出现在某些屏幕中,而不出现在其他人的android版本APK中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆