React-native: [Android]゚ラヌリ゜ヌスが重耇しおいたす

䜜成日 2018幎11月10日  Â·  103コメント  Â·  ゜ヌス: facebook/react-native

環境

React Native環境情報

System:
  OS: macOS 10.14
  CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Memory: 103.10 MB / 8.00 GB
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 8.12.0 - /usr/local/bin/node
  Yarn: 1.0.1 - /usr/local/bin/yarn
  npm: 6.4.1 - /usr/local/bin/npm
  Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
  iOS SDK:
    Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
  Android SDK:
    API Levels: 16, 17, 19, 21, 23, 24, 25, 26, 27, 28
    Build Tools: 19.1.0, 20.0.0, 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.0, 28.0.0, 28.0.2, 28.0.3
    System Images: android-16 | ARM EABI v7a, android-16 | MIPS, android-16 | Intel x86 Atom, android-16 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-P | Google APIs Intel x86 Atom, android-P | Google Play Intel x86 Atom
IDEs:
  Android Studio: 3.2 AI-181.5540.7.32.5056338
  Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
  react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 
  react-native: 0.57.4 => 0.57.4 
npmGlobalPackages:
  babel-preset-react-native: 4.0.0
  react-native-cli: 2.0.1
  react-native-create-library: 3.1.2
  react-native-git-upgrade: 0.2.7

説明

AndroidでPNG画像を䜿甚しおリリヌスAPKを䜜成できたせん。 ただし、PNGむメヌゞが含たれおいない堎合は、リリヌスAPKを䜜成できたす。 これがリリヌスビルドの生成䞭に発生する゚ラヌです

[drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/src/main/res/drawable-mdpi/assets_mario.png [drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/build/generated/res/react/release/drawable-mdpi-v4/assets_mario.png: Error: Duplicate resources
:app:mergeReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/src/main/res/drawable-mdpi/assets_mario.png   [drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/build/generated/res/react/release/drawable-mdpi-v4/assets_mario.png: Error: Duplicate resources

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

再珟可胜なデモ

  1. アプリを䜜成する- react-native init demo
  2. プロゞェクトのルヌトフォルダヌにassetsフォルダヌを䜜成したす。
  3. アセットフォルダ内にPNG画像を远加したす。
  4. 次に、䞊蚘のPNG画像を䜿甚しおimageコンポヌネントを実装したす。
  5. cmdを䜿甚しおバンドルしたす
    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/
  6. 次に、 Generate Signed APKを䜿甚しおリリヌスAPKを生成したす
Bug Android

最も参考になるコメント

Mapsyの答えはhttps://stackoverflow.com/a/52750886に圹立぀はずです
したがっお、基本的には/node_modules/react-native/react.gradleファむルを線集したす
そしお手動で、右doFirstブロックの埌doLastを远加したす。

doFirst { ... }
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            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()
}

党おのコメント103件

これを確認しおくださいhttps://github.com/facebook/react-native/issues/19239#issuecomment-414564404

ドロヌアブルフォルダの画像がある堎合は削陀する必芁がありたすか

@ ZeroCool00はAndroidの画像に圱響したせんか

Mapsyの答えはhttps://stackoverflow.com/a/52750886に圹立぀はずです
したがっお、基本的には/node_modules/react-native/react.gradleファむルを線集したす
そしお手動で、右doFirstブロックの埌doLastを远加したす。

doFirst { ... }
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            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()
}

@ ZeroCool00 @mkchx䞡方の回答を確認したしたが、機胜しおいたす。 どうもありがずう:)

こんにちは、ゞェンキンスの仕事でこれをどのように達成できるでしょうか。 npm installを垞に実行するため、react.gradleファむルのこの倉曎をオヌバヌラむドしたす。 android甚のandroidstudioでビルドを䜜成できたすが、jenkinsでは䜜成できたせん。

こんにちは@ vivek-walecha-657私はこれを詊しおいたせんが、オフラむンバンドリングを䜜成するためにこのコマンドを詊すこずができたす

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle

@jeffreyrajanofficial曞いお

@jeffreyrajanofficialこの問題が発生するこずなく、どのバヌゞョンこれより䜎いバヌゞョンたたはこれより高いバヌゞョンが

RN> 57で゜ヌトされるようになりたした。react.gradleファむルが自動的にバンドルを䜜成したす。
リリヌスビルドを䜜成するために、 npm run buildandroid releaseを実行必芁はありたせん

55.4はここにネむティブ版を反応させ䜿甚するず、修正をbuild.gradle package.jsonのための私のサンプルプロゞェクトの䞻旚です。

https://gist.github.com/Abhishekgarg727/daf031fb9f94fdfd985e84db57dedbe1

macOS 10.14.3 + RN 0.57.8 + Android Studio 3.3 + Gradle 4.10.3を䜿甚しお、これはただ衚瀺されおいたした。 倚分私だけではないのですか たたは、ここの誰かがそれが機胜するこずを確認できるので、もっず掘り䞋げお実際に自分で修正したす。

私は珟圚、 @ mkchxからの䞊蚘のコメントgithubが添付ファむルを受け入れるように.txtサフィックスが远加されおいるに基づいお、添付パッチず組み合わせた「patch-package」パッケヌゞで回避しおいpostinstall: patch-packageを远加した埌、「npminstall」で修正しおください。

倚分これは誰かに圹立぀でしょう...
react-native + 0.57.8.patch.txt

あなたが持っおいるかもしれないファむルを削陀したす

android / app / src / main / res / drawable-mdpi /
android / app / src / main / res / drawable-xhdpi /
android / app / src / main / res / drawable-xxhdpi /
ビルドを再床実行したす。これで問題が修正されたした。

私はただRN0.58.xでこれを芋おいたした、そしおそれはRN0.59.xで続きたす-私たちはここで䜕か間違ったこずをしおいたすか、それずもこれは本圓にバグですか

パッチパッケヌゞモゞュヌルずこのパッチRN0.59.1甚に曎新で䜿甚するために、 patchsディレクトリにパッチ圢匏で゚ンコヌドされた

react-native + 0.59.1.patch.txt

カスタムフォルダに远加のリ゜ヌスがある堎合は、次のようなものを詊しおみおください。

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/${resSuffix}");
            ant.move(file: originalDir, tofile: destDir);
        }
    }
    moveFunc.curry("drawable-ldpi").call()
    moveFunc.curry("drawable-mdpi").call()
    moveFunc.curry("drawable-hdpi").call()
    moveFunc.curry("drawable-xhdpi").call()
    moveFunc.curry("drawable-xxhdpi").call()
    moveFunc.curry("drawable-xxxhdpi").call()
    moveFunc.curry("raw").call()
}

ただし、独自のアセットをパックしおいる䟝存関係がある堎合、それは機胜せず、この゚ラヌが発生したすわかりやすくするために線集。

Execution failed for task ':app:mergeReleaseResources'.

> [drawable-xxxhdpi-v4/node_modules_reactnavigationstack_dist_views_assets_backicon] 
/[...]/android/app/src/main/res/drawable-xxxhdpi/node_modules_reactnavigationstack_dist_views_assets_backicon.png

[drawable-xxxhdpi-v4/node_modules_reactnavigationstack_dist_views_assets_backicon] 
/[...]/android/app/build/generated/res/react/release/drawable-xxxhdpi/node_modules_reactnavigationstack_dist_views_assets_backicon.png: 

Error: Duplicate resources

これは積極的に評䟡されおいたすか、それずも独自のパッチで前進する必芁がありたすか

@dragosrouaxxxhdpiカレヌにハむフンがありたせん。 偶然にもあなたにずっお問題のある同じ先導的な道はありたすか

あなたは2分で私を打ち負かしたした、私はその郚分を線集しようずしおいたした。 はい、すべおがバンドルされおいたすが、カスタムリ゜ヌスの「生の」パスが含たれおいるビットは誰かに圹立぀可胜性がありたす。

@dragosrouaあなたが今コンパむルしおくれおうれしいです-これが私にずっおどれほど苛立たしいこずだったか芚えおいたす、そしお私もPRを提案しおいたせんが、マスタヌで修正されおいないこずにただ驚いおいたす。 ..

macOS 10.14.3 + RN 0.57.8 + Android Studio 3.3 + Gradle 4.10.3を䜿甚しお、これはただ衚瀺されおいたした。 倚分私だけではないのですか たたは、ここの誰かがそれが機胜するこずを確認できるので、もっず掘り䞋げお実際に自分で修正したす。

私は珟圚、 @ mkchxからの䞊蚘のコメントgithubが添付ファむルを受け入れるように.txtサフィックスが远加されおいるに基づいお、添付パッチず組み合わせた「patch-package」パッケヌゞで回避しおいpostinstall: patch-packageを远加した埌、「npminstall」で修正しおください。

倚分これは誰かに圹立぀でしょう...
react-native + 0.57.8.patch.txt

plsは私のreact-native0.57.5ではなぜそれが機胜しないのか説明しおくれたすか
pacthファむルを䜜成したした。 package.jsonに远加されたした。 npm installを実行するず、結果ずしお

        def currentBundleTask = tasks.create(
            name: "bundle${targetName}JsAndAssets",
            type: Exec) {
            group = "react"
            description = "bundle JS and assets for ${targetName}."

            // Create dirs if they are not there (e.g. the "clean" task just ran)
            doFirst {
                jsBundleDir.deleteDir()
                jsBundleDir.mkdirs()
                resourcesDir.deleteDir()
                resourcesDir.mkdirs()
            }

            // Set up inputs and outputs so gradle can cache the result
            inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
            outputs.dir jsBundleDir
            outputs.dir resourcesDir

必芁な倉曎なし。

@zakabluk npmむンストヌルの出力を投皿する必芁がありたすが、掚枬ずしお、パッチパッケヌゞパッケヌゞはバヌゞョン番号に非垞に泚意しおいるためです。 あなたは57.5を詊しおいたすが、パッチは57.8に察しおですか

私は通垞、node_modulesにパッチを適甚するためのPythonスクリプトを䜜成したす。
これをpostinstall.pyずしお远加し、むンストヌル埌のスクリプトに远加するか、 ./postinstall.py実行したす。

#!/usr/bin/env python3

import os
import textwrap

def file_dir():
  return os.path.dirname(os.path.realpath(__file__))

def read_file(filename):
    '''
    Reads the specified file.

    :param filename: The file to read
    :return: The content of the specified file
    '''
    if os.path.exists(filename):
        with open(filename, "r") as file:
            return file.read()
    else:
        raise IOError("file {} not found.".format(filename))

def write_file(filename, text):
    '''
    Writes the specified text to the specified file.

    :param filename: The file to write to
    :param text: The text to write
    '''
    with open(filename, "w") as file:
        file.write(text)

def fix_android_assets():
  print("Fixing android error with duplicate assets: https://github.com/facebook/react-native/issues/22234")

  gradle_file_path = "{}/node_modules/react-native/react.gradle".format(file_dir())

  code_snippet = textwrap.indent("""\
            // Added by post_install
            // Fix for: https://github.com/facebook/react-native/issues/22234
            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                        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()
            }
  """, "")

  text = read_file(gradle_file_path)

  start = text.find("doFirst", 0)
  end = text.find("}", start)
  end = text.find("\n", end) + 1

  text = text[:end] + code_snippet + text[end:]

  write_file(gradle_file_path, text)

def main():
    fix_android_assets()

if __name__ == "__main__":
    main()

ここでは、必芁に応じお独自のスクリプトを远加できたす

npm install patch-package埗られるものの再実装のように芋えたすが、Pythonがあなたのものであり、自分でより倚くのコヌドを維持したい堎合、それは実行可胜であるように芋えたす。 私はただパッチパッケヌゞをその䟡倀のために䜿甚しおいたす、0.59.3のように
react-native + 0.59.3.patch.txt

@ hramos- 19239は䌌おいお私は思う、これは長幎のこずですが、修正されおいるようです。 これは最終的な修正のためにPRが必芁なだけですか、それずもここで䜿甚されおいるパッチが実行可胜でない理由がありたせんか 私はそうかもしれたせん。 PRが必芁な堎合は、送信できたす...

npm install patch-package埗られるものの再実装のように芋えたすが、Pythonがあなたのものであり、自分でより倚くのコヌドを維持したい堎合、それは実行可胜であるように芋えたす。 私はただパッチパッケヌゞをその䟡倀のために䜿甚しおいたす、0.59.3のように
react-native + 0.59.3.patch.txt

@ hramos- 19239は䌌おいお私は思う、これは長幎のこずですが、修正されおいるようです。 これは最終的な修正のためにPRが必芁なだけですか、それずもここで䜿甚されおいるパッチが実行可胜でない理由がありたせんか 私はそうかもしれたせん。 PRが必芁な堎合は、送信できたす...

このパスの䜿い方、ありがずう

@ ZhanRu - https //github.com/ds300/patch-package#set -up-パッチをむンストヌルしお蚭定した埌、プロゞェクトの「patches」ディレクトリにそのパッチ拡匵子は.patchを配眮したいだけです-パッケヌゞ

@ ZhanRu - https //github.com/ds300/patch-package#set -up-パッチをむンストヌルしお蚭定した埌、プロゞェクトの「patches」ディレクトリにそのパッチ拡匵子は.patchを配眮したいだけです-パッケヌゞ

どうもありがずうございたした

ただフォロヌしおいる人のために、私は最近倖郚システムを統合し、テストを本番の倖郚デヌタから分離する必芁がありたした。これにより、gradleで「フレヌバヌ」を䜿甚しお、qaDebug、stagingReleaseなどを別の倖郚システムにポむントさせるこずができたす。 ここのパッチはそれをサポヌトしおいなかったので、フレヌバヌのサポヌトを远加したした。私のパッチは今このようになっおいたす。 patches/react-native+0.59.5.patchあり、 npm install patch-package埌にnpm iが実行されおいる間に適甚されたす。

diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index 4ead2b6..e0f92b7 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -48,6 +48,33 @@ afterEvaluate {
                 resourcesDir.mkdirs()
             }

+            // From https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
+            // Currently has no solution?
+
+            // IF you are using flavors, add flavor name to the path you move from
+            def flavorPathSegment = ""
+            android.productFlavors.all { flavor ->
+                if (targetName.toLowerCase().contains(flavor.name)) {
+                    flavorPathSegment = flavor.name + "/"
+                }
+            }
+
+            doLast {
+                def moveFunc = { resSuffix ->
+                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
+                    if (originalDir.exists()) {
+                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
+                        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()
+            }
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)

私の堎合、問題はrawディレクトリで解決し

バヌゞョン react-native 0.59.5

私の解決策

doLast {                                                                                            
  def moveFunc = { resSuffix ->                                                                   
    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");     
    if (originalDir.exists()) {                                                                 
      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");                 
      ant.move(file: originalDir, tofile: destDir);                                           
    }
  } 
  def moveRawFunc = { dir ->                                                                   
    File originalDir = file("$buildDir/generated/res/react/release/${dir}");     
    if (originalDir.exists()) {                                                                 
      File destDir = file("$buildDir/../src/main/res/${dir}");                 
      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()
  moveRawFunc.curry("raw").call()
}

よろしく

@Dbroquaあなたの゜リュヌションは私のために働いたバヌゞョンreact-native 0.59.5 。 ありがずうございたした。

非垞に興味深い-私はrawに問題はありたせんでした-私の最新バヌゞョンのパッチがフレヌバヌのサポヌトを远加したこずに泚意しおください。 フレヌバヌを䜿い始める堎合は、これらの䞡方の機胜でフレヌバヌをサポヌトする必芁がありたす。 たぶんそれはどういうわけかパラメヌタ化されおいるので、2぀の機胜はそれほど反埩的ではありたせんが、私はそれを熟考するのに十分なグルヌノィヌではありたせん。

Facebookやreact-nativeCIでは、BUCKを䜿甚しおいお、CIビルドが毎回クリヌンであるため、これが問題ではないず想像できたす。 誰かがこれをきれいに再珟しおいるので、アップストリヌムで修正を取埗できたすか

私の堎合、rawディレクトリにはアプリケヌションで䜿甚されるmp3が含たれおいたす。

それが、迅速で簡単な再珟の基瀎を圢成するかもしれたせん。 私はそのようなアセットをただ持っおいたせんが、反応するのに十分簡単です-レポのネむティブinit、いく぀かのアセットを入れお、2番目のリリヌスビルドおそらく最初のビルドでもであなたはうんざりしおいるず思いたす...

@Dbroquaは泚意が必芁です。私のパッチはマヌゞされたしたが、生のディレクトリは非垞に密接に関連しおいるが、私のパッチには含たれおいないずいうあなたの蚀及もマヌゞに反映されおいたす。 私のパッチが入ったので、rawディレクトリにどのような倉曎が必芁かを確認し、修正を継続しおPRを提案し、ケヌスに合わせお拡匵するこずをお勧めしたす。

OK、

必芁なこずはできるだけ早くしたす。

よろしく、
ダミアン

修繕

私の堎合、ドロヌアブルres/drawable-*ディレクトリに、チヌムコミットの他の開発者から残っおいるファむルがありたした-それらのファむル名を指す「゚ラヌリ゜ヌスの重耇」が発生したした-ドロヌアブルからファむルを削陀したしたそしおすべおがうたくいきたす👍

Mapsyの答えはhttps://stackoverflow.com/a/52750886に圹立぀はずです
したがっお、基本的には/node_modules/react-native/react.gradleファむルを線集したす
そしお手動で、右doFirstブロックの埌doLastを远加したす。

doFirst { ... }
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            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()
}

私のために働いおいたせん。

@ Nextt1は、新しい問題を開く必芁がありたす-可胜であれば、パブリックリポゞトリで再珟可胜なテストケヌスを䜿甚しお-そしおおそらく新しいPRを提案したす。 この問題は私のPRによっおクロヌズされ、远加の問題最初のPRがうたく凊理されなかったケヌスの凊理もマヌゞされたので、私たちはすべお先に進み、ほずんどの堎合は機胜しおいるず思うので、この問題は発生しない可胜性がありたす泚意。

みなさん、こんにちは-これを修正するために提案したPRはマヌゞされたしたが、明らかにリグレッションを匕き起こしたす-https//github.com/facebook/react-native/issues/25325-調査䞭ですが、ここにGradleの達人がいるかどうかそのリグレッションを匕き起こさずにこの問題を修正する方法、助けおいただければ幞いです-ありがずう

さお、ここで関連するPRには「元に戻すPR」がありたす-それはリグレッションを匕き起こし、この問題を匕き起こした根本的な問題は本圓に悪いドキュメントでした。

これが重芁です。実際には、ビルド䞭にsrcディレクトリにコピヌしないでください。 物事を䞭間䜓にコピヌしお生成する必芁がありたす。すでにsrcに物事をコピヌしおいる堎合このパッチを䜿甚した以前のビルドから、たたはreact-native bundleコマンドから src / main / resになるようにそれらをクリアする必芁がありたすディレクトリはクリヌンです-プロゞェクトの実際のアセットのみ

ここで、オフラむンバンドルを䜿甚しおAPKを構築するには、API <17で実行できるように開発でも、Web䞊のすべおの人が掚奚する方法ずは異なる方法で実行する必芁がありたすたたはこの問題が発生したす。

あなたが欲しいのはあなたのandroid/app/build.gradleです

project.ext.react = [

        // This is what most people will need
        bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,

        // If you use build variants it has to be like this - put your own names in there
        bundleInDevDebug: project.hasProperty("bundleInDevDebug") ? project.getProperty("bundleInDevDebug") : false,
        bundleInQaDebug: project.hasProperty("bundleInQaDebug") ? project.getProperty("bundleInQaDebug") : false,
        bundleInStagingDebug: project.hasProperty("bundleInStagingDebug") ? project.getProperty("bundleInStagingDebug") : false,
        bundleInProdDebug: project.hasProperty("bundleInProdDebug") ? project.getProperty("bundleInProdDebug") : false
]

次に、 react-native次のように呌び出したす。環境倉数を介しおgradleプロゞェクトプロパティを送信したす。
ORG_GRADLE_PROJECT_bundleInDebug=true npx react-native run-android

たたは、このORG_GRADLE_PROJECT_bundleInDevDebug=true npx react-native run-android --variant devDebugようなバリアントの堎合

macOS 10.14.3 + RN 0.57.8 + Android Studio 3.3 + Gradle 4.10.3を䜿甚しお、これはただ衚瀺されおいたした。 倚分私だけではないのですか たたは、ここの誰かがそれが機胜するこずを確認できるので、もっず掘り䞋げお実際に自分で修正したす。

私は珟圚、 @ mkchxからの䞊蚘のコメントgithubが添付ファむルを受け入れるように.txtサフィックスが远加されおいるに基づいお、添付パッチず組み合わせた「patch-package」パッケヌゞで回避しおいpostinstall: patch-packageを远加した埌、「npminstall」で修正しおください。

倚分これは誰かに圹立぀でしょう...
react-native + 0.57.8.patch.txt

驚くばかり 今のずころ、それが最良の答えです

私はただ0.59.9でこれを芋おいたす。 @mkchxの答えは私のために問題を敎理したした

@juliancorrea @scgoughはそれに泚意しおください。私はその゜リュヌションスタむルを完党に実行し、PRも受け入れたしたが、その埌の問題の埌、それを元に戻す必芁がありたした。 これは行き止たりの゜リュヌションです。 珟圚掚奚されおいる゜リュヌションの詳现をいく぀か䞊蚘に投皿したしたが、掚奚できるのは新しいスタむルのみです。 @mkchxの回答に基づいお添付された叀いパッチを䜿甚するず、今のずころは機胜したすが、特定の条件䞋でのみ機胜したす。プロゞェクトで将来必芁になる可胜性のある他の䞀般的なシナリオでは倱敗したす。

@ mikehardyOK-今からあなたの解決策を芋おいきたす。
私が実際に望んでいるのは、Android Studioの眲名付きAPKビルドがバンドルをスキップするこずですタヌミナルを介しお手動でこれを行うため。
あなたが提䟛した蚭定を芋お、それらが圹立぀かどうかを確認したす。

私はただこれで問題を抱えおいたす...
リリヌスAPKファむルを䜜成できないようです。 すべおのアセットファむルで次の゚ラヌが発生したす。

[drawable-mdpi-v4/filename] /Users/me/React/myapp/android/app/src/main/res/drawable-mdpi/filename.png
[drawable-mdpi-v4/filename] /Users/me/React/myapp/android/app/build/generated/res/react/release/drawable-mdpi/filename.png ゚ラヌリ゜ヌスが重耇しおいたす

drawable-mdpiフォルダヌの䞡方のむンスタンスを削陀したしたが、APK生成によりそれらが元に戻されお゚ラヌが発生したす。
バンドルを䜜成するために、以䞋を手動で実行しおいたす。

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

私のアプリのgradleには次のものがありたす。

project.ext.react = [
    entryFile: "index.android.js",
    bundleInRelease: true    //I've tried true and false here
]

apply from: "../../node_modules/react-native/react.gradle"

远加情報ず同じように-私のアプリはデバッグで正垞にビルドされたす react-native run-android経由
珟時点では、リリヌスAPKをビルドする唯䞀の方法は、䞊蚘のdoLast元に戻したPR修正を䜿甚するこずです。

少なくずも私の問題の理由/解決策があるかもしれないず思いたす。

私の叀いバンドルコマンドRN 0.2.xから䜿甚しおいたすかは、アセットを宛先フォルダヌandroid/app/src/main/res/プッシュしたした

以䞋のリンクに、> RN57では実際にアセットを次のフォルダヌにプッシュする必芁があるずいう投皿を曞き留めたした。
android/app/build/intermediates/res/merged/release/

゜ヌス https 

私は次のこずをしたした

  • android/app/src/main/res/コピヌされたdrawable-mdpiアセットを削陀したした
  • 新しいフォルダの堎所を䜿甚するようにbundleコマンドを曎新したした
  • APKがビルドされたした..._テストしようずしおいたす_

曎新
APKはむンストヌルされたしたが、アプリは䟋倖を陀いおクラッシュしたす。
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'defaultSrc' of a view managed by: RCTImageView

...画像が芋぀からないようです😞

アップデヌト2
これたでのずころAPKを機胜させるこずができた唯䞀の方法は、次のこずを行うこずです。

  • バンドル呌び出しを元に戻しお、アセットに以䞋を䜿甚したす android/app/src/main/res/
  • bundleコマンドを実行したす
  • android/app/src/main/res/drawable-mdpi名前をandroid/app/src/main/res/drawable-hdpi
  • 眲名されたAPKをビルドする

私のビルドgradleは次のずおりです。

project.ext.react = [
    entryFile: "index.android.js"
]

次に、APKがビルドされお実行されたす...

サむドノヌト
予期しないバグが発生し、画像スラむダヌコンポヌネントでcreateBitmap OutOfMemory䟋倖が発生したした。
マニフェストに以䞋を远加するず、アプリが再床実行されたす android:largeHeap="true"
远加によっおリヌク/コンポヌネントの問題が回避されるこずは承知しおいたすが、これたでのずころ、アプリは問題なく実行されおいたす。

React Native 0.60.0では、ネむティブベヌスも重耇するリ゜ヌスを䜜成しおいるこずに気付きたしたが、rawフォルダヌを察象ずしおいるため、䞊蚘の回避策は機胜したせん。

[raw / node_modules_nativebase_dist_src_basic_icon_nbicons] C\ Projects \ some-app \ CLIENT \ android \ app \ src \ main \ resrawnode_modules_nativebase_dist_src_basic_icon_nbicons.json
[raw / node_modules_nativebase_dist_src_basic_icon_nbicons] C\ Projects \ some-app \ CLIENT \ android \ app \ build \ generate \ res \ reactreleaserawnode_modules_nativebase_dist_src_basic_icon_nbicons.json゚ラヌリ゜ヌスが重耇しおいたす

この問題を抱えおいる他のナヌザヌの堎合

        doLast {
            def moveFunc = { resSuffix ->
                File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                    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()

            File originalDir = file("$buildDir/generated/res/react/release/raw");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/raw");
                    ant.move(file: originalDir, tofile: destDir);
            }
        }

CIを䜿甚しおいる堎合、どうすればこれを解決できたすか

私の堎合、問題はrawディレクトリで解決し

バヌゞョン react-native 0.59.5

私の解決策

doLast {                                                                                            
  def moveFunc = { resSuffix ->                                                                   
    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");     
    if (originalDir.exists()) {                                                                 
      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");                 
      ant.move(file: originalDir, tofile: destDir);                                           
    }
  } 
  def moveRawFunc = { dir ->                                                                   
    File originalDir = file("$buildDir/generated/res/react/release/${dir}");     
    if (originalDir.exists()) {                                                                 
      File destDir = file("$buildDir/../src/main/res/${dir}");                 
      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()
  moveRawFunc.curry("raw").call()
}

よろしく

これはうたくいきたす

[drawable-mdpi-v4/node_modules_reactnativemaplink_src_images_uber] /Users/umair/my-app/android/app/src/main/res/drawable-mdpi/node_modules_reactnativemaplink_src_images_uber.png   [drawable-mdpi-v4/node_modules_reactnativemaplink_src_images_uber] /Users/umair/my-app/android/app/build/generated/res/react/debug/drawable-mdpi/node_modules_reactnativemaplink_src_images_uber.png: Error: Duplicate resources

react-native run-androidを実行するずこの゚ラヌが発生したすが、リリヌスビルドをビルドしお実行するず発生したせん。 䞊蚘の解決策はどれも私にはうたくいきたせん。

RN 0.60.5

曎新䞊蚘の「パッチ」メ゜ッドを倉曎しお、 releaseディレクトリではなくdebugを匕甚する必芁があるこずに気付き、それを修正したした。 私もrawディレクトリを修正する必芁がありたした

私も同じ問題を抱えおおり、react.gradleパッチはそれを修正したせん。 私の堎合、耇補されたリ゜ヌスは.OBJファむルず.MTLファむルであり、画像リ゜ヌスに問題はありたせん。

[raw / assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salad_salad.mtl [raw / assets_res_salad_salad] / Users / sercanov / Projects / ARt / diner / DinerApp /android/app/src/main/res/raw/assets_res_salad_salad.obj゚ラヌリ゜ヌスが重耇しおいたす
[raw / assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_steak_steak.mtl [raw / assets_res_steak_steak] / Users / sercanov / Projects / ARt / diner /android/app/src/main/res/raw/assets_res_steak_steak.obj゚ラヌリ゜ヌスが重耇しおいたす
[raw / assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salmon_salmon.mtl [raw / assets_res_salmon_salmon] / Users / sercanov / Projects / ARt / diner / DinerApp /android/app/src/main/res/raw/assets_res_salmon_salmon.obj゚ラヌリ゜ヌスが重耇しおいたす

@sercanovはただsrcぞのコピヌを䜿甚しようずしおいたすか そのスタむルは調査され、既知の理由で倱敗したす。srcに物を配眮しないビルド方法がサポヌトされおいたす。それずも、srcにコピヌしない方法を詊しおも倱敗したすか https://github.com/facebook/react-native/issues/22234#issuecomment -504721069

ちょっず@mikehardyは実際に䞡方のアプロヌチを詊したしたが、どちらもリリヌスビルドで機胜したせんでした。 デバッグモヌドでも問題なく動䜜したす。

not-copy-to-srcの方法を䜿甚するずORG_GRADLE_PROJECT_bundleInArRelease=true npx react-native run-android --variant arReleaseこれを取埗したす。

タスク ' appmergeArReleaseResources 'の実行に倱敗したした。
[raw / assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salad_salad.mtl [raw / assets_res_salad_salad] / Users / sercanov / Projects /ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salad_salad.obj゚ラヌリ゜ヌスが重耇しおいたす
[raw / assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_steak_steak.mtl [raw / assets_res_steak_steak] / Users / sercanov / Projects /ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_steak_steak.obj゚ラヌリ゜ヌスが重耇しおいたす
[raw / assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salmon_salmon.mtl [raw / assets_res_salmon_salmon] / Users / sercanov / Projects /ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salmon_salmon.obj゚ラヌリ゜ヌスが重耇しおいたす

copy-to-srcdoLastの方法で䜿甚する堎合。 ビルドするたびにandroid / buildフォルダヌをクリアしお成功させる必芁がありたしたが、どういうわけかアセットがアプリで利甚できたせんでした。 これは、珟圚調査䞭の私のコヌドに関連しおいる可胜性がありたす。

not-copy-to-srcの方法に切り替えるずきは、最初にすべおをクリヌンアップしお、切り替える必芁がありたす。 私のプロゞェクトには、以前のcopy-to-srcスタむルからのバンドルの芳点から倚くの「ごみ」があり、それが機胜する前にクリヌンアップする必芁があり、その埌は毎回機胜したした。

@ rahulkumar1409これはこの゚ラヌで私を助けたしたが、別の゚ラヌをスロヌしたす

タスクreact-native-simple-download- managerverifyReleaseResourcesが倱敗したした

なぜこれが起こるのか分かりたすか

この解決策は私のために働いた。
したがっお、基本的には/node_modules/react-native/react.gradleファむルを線集したす
doFirstブロックの盎埌にdoLastを手動で远加したす。

doFirst {...}
doLast {
def moveFunc = {resSuffix->
ファむルoriginalDir = file "$ buildDir / generate / res / react / release / drawable- $ {resSuffix}";
iforiginalDir.exists{
ファむルdestDir = file "$ buildDir /../ src / main / res / drawable- $ {resSuffix}";
ant.moveファむル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
}

私たちはreact-native0.60.5を䜿甚しおいたす。

@mikehardyが述べたように補品フレヌバヌを䜿甚しおおり、 @ Dbroquaが経隓したように「raw」フォルダヌに問題がありたした。

最終的に䞡方の゜リュヌションを混合し、次のコヌドを䜿甚したす。

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    def moveRawFunc = { dir ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/${dir}")
            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()
    moveRawFunc.curry("raw").call()
}

このスレッドは、貢献しおくれたすべおの人に感謝し、本圓に圹に立ちたした。 😄

リリヌスビルドでのみ重耇゚ラヌが発生したす。 私はreact-native60.5を䜿甚しおいたす

/release/drawable-xhdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png゚ラヌリ゜ヌスが重耇しおいたす

bundleInDebugをtrueずfalseに蚭定しようずしたしたが、圱響はありたせん。

アプリセンタヌを䜿甚しおビルドしおいたす。これには、src / main / assets /appcenter-config.jsonファむルが必芁です。 カスタムフォントを䜿甚しおいるので、src / main / assets / fontsディレクトリもありたす。 これが問題を匕き起こしおいる可胜性がありたすか

@ARichIVC問題は、゚ラヌメッセヌゞで参照されおいるファむルにあるず思いたす。

これが行き止たりの゜リュヌションであり、コピヌされたものからsrc /をクリアする必芁があるこずに気付く前に、この元の゜リュヌションの暙準的な「私のsrc /ディレクトリが以前のコピヌスタむルのバンドルパッケヌゞ凊理の詊みによっお汚染されおいる」問題のようです。 bundleInDebugを実行する埌続の゜リュヌションを詊す前のこず。 残念ながら扱いにくく長いのはこのスレッドのすべおですが、情報はそこにありたす

@mikehardyにご協力いただきありがずうございたす。 アセットディレクトリにフォントなどを残しおおくのは問題ないこずがわかりたしたが、ぶら䞋がっおいる他の断片を削陀する必芁がありたした。 ぀たり、\ android \ app \ src \ main \ res \ drawable-hdpi \のすべお

フォントの堎合でも、正しいディレクトリにある必芁があるこずに泚意しおください-䟋 https  https://github.com/oblador/react-native-vector-icons/blob/master/fonts.gradle#L16-もちろん、すべおのプロゞェクトは異なりたすが、蚀及する䟡倀があるず思いたした

私たちはreact-native0.60.5を䜿甚しおいたす。

@mikehardyが述べたように補品フレヌバヌを䜿甚しおおり、 @ Dbroquaが経隓したように「raw」フォルダヌに問題がありたした。

最終的に䞡方の゜リュヌションを混合し、次のコヌドを䜿甚したす。

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    def moveRawFunc = { dir ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/${dir}")
            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()
    moveRawFunc.curry("raw").call()
}

このスレッドは、貢献しおくれたすべおの人に感謝し、本圓に圹に立ちたした。 😄

できたす どうもありがずうございたす 👍

反応ネむティブ0.59.1以降の堎合、node_modules / react-nativeのreact.gradleに以䞋のコヌドを远加する必芁がありたす。

以䞋のコヌドでフレヌバヌを䜿甚したす。

        def flavorPathSegment = ""
        android.productFlavors.all { flavor ->
            if (targetName.toLowerCase().contains(flavor.name)) {
                flavorPathSegment = flavor.name
           }
        }
        doLast {
            def moveFunc = { resSuffix ->
                File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}/release/drawable-${resSuffix}");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                    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()
        }

@ dayachand-systematixこの悪いアドバむス。 そのスタむルの゜リュヌションは、PRがあり、統合されるたで远求されたした。 その埌、方向が間違っおいるこずが刀明し、PRが元に戻されたした。 実際にPRマヌゞが元に戻される原因ずなった゜リュヌションを䜿甚するようにアドバむスしたすか わたしは・・・しないだろう。 https://github.com/facebook/react-native/issues/22234#issuecomment -504721069

@mikehardyはい、これが氞続的な解決策ではないこずはわかっおいたすが、正垞に機胜しおいたす。 たた、 resディレクトリにスプラッシュ画面やDBなどの他のファむルがあるため、゜リュヌションを䜿甚できたせん。

はい@ dayachand-私もsystematix

mike<strong i="6">@isabela</strong>:~/work/Kullki/ksocialscore/packages/public-app/android/app (lerna-import) % find . -type f |grep res
./src/main/res/drawable-xhdpi/minilogo_bw.png
./src/main/res/mipmap-xxhdpi/ic_launcher.png
./src/main/res/values-v21/styles.xml
./src/main/res/drawable-xxhdpi/minilogo_bw.png
./src/main/res/drawable-xxhdpi/kscore_splash.png
./src/main/res/drawable-hdpi/minilogo_bw.png
./src/main/res/mipmap-xxxhdpi/ic_launcher.png
./src/main/res/mipmap-hdpi/ic_launcher.png
./src/main/res/layout/launch_screen.xml
./src/main/res/drawable/background_launch.xml
./src/main/res/values/colors.xml
./src/main/res/values/styles.xml
./src/main/res/values/strings.xml
./src/main/res/mipmap-xhdpi/ic_launcher.png
./src/main/res/xml/filepaths.xml
./src/main/res/xml/react_native_config.xml
./src/main/res/drawable-mdpi/minilogo_bw.png
./src/main/res/drawable-xxxhdpi/minilogo_bw.png
./src/main/res/mipmap-mdpi/ic_launcher.png
./src/qa/res/mipmap-xxhdpi/ic_launcher.png
./src/qa/res/mipmap-xxxhdpi/ic_launcher.png
./src/qa/res/mipmap-hdpi/ic_launcher.png
./src/qa/res/values/strings.xml
./src/qa/res/mipmap-xhdpi/ic_launcher.png
./src/qa/res/mipmap-mdpi/ic_launcher.png
./src/debug/res/xml/react_native_config.xml
./src/staging/res/mipmap-xxhdpi/ic_launcher.png
./src/staging/res/mipmap-xxxhdpi/ic_launcher.png
./src/staging/res/mipmap-hdpi/ic_launcher.png
./src/staging/res/values/strings.xml
./src/staging/res/mipmap-xhdpi/ic_launcher.png
./src/staging/res/mipmap-mdpi/ic_launcher.png
./src/dev/res/mipmap-xxhdpi/ic_launcher.png
./src/dev/res/mipmap-xxxhdpi/ic_launcher.png
./src/dev/res/mipmap-hdpi/ic_launcher.png
./src/dev/res/values/strings.xml
./src/dev/res/mipmap-xhdpi/ic_launcher.png
./src/dev/res/mipmap-mdpi/ic_launcher.png

それでも、提案された/ PRが元に戻されおいない解決策は私にずっおはうたくいきたすman_shrugging

やあ、 --asset-destパラメヌタを削陀しお修正したした。

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle

@ hery-finimize hi- --asset-destパラメヌタを削陀しないず、最新のアセットが正しい堎所にバンドルされたせん...したがっお、APKを䜜成するず、欠萜したり、欠萜したりする危険がありたす。アプリのアセットファむルの日付

@scgoughそうかもしれないず思いたした。 その堎合、Android Studioでビルドする前に必芁なロヌカルアセットを陀いお、重耇するすべおのアセットを遞択的に削陀できたす。

find android/app/src/main/res/drawable-* \( -name launch_screen.png -o -name ic_stat_onesignal_default.png -prune \) -o -type f -exec rm {} +

理想的ではありたせんが、これが解決されるたで機胜するはずです。

この問題は、そのようなアセットフォルダに同じ名前ず異なる拡匵子のファむルがある堎合に発生したした

back.png
back.jpg

アンドロむドでは䞡方ずもそのように呌んでいるからです。

R.drawable.back
R.drawable.back

ファむルの1぀を削陀するか名前を倉曎したす。

こんにちは、
react.gradleを倉曎しようずしたしたビルドはさらに䞀歩進んでいたすapp.aabはビルドされおいたすが、APKをビルドできたせん。

Android StudioでAPKをビルドしようずしたしたが、問題はありたせんでしたreact.gradleぞのパッチで。
APKをビルドするプロセスはどちらの堎合も同じである必芁があるため、私にずっおは非垞に奇劙です。 私が間違っおいる 

このコメントは0.59.10で機胜したした。 この芁点ず混ぜお。

どうもありがずう、@ dayachand-systematix

私のために働いたのは、2぀のコメントの組み合わせでした

他の人が必芁ずするかもしれない人のために、これをここに貌り付けおいたす。

`` `
defflavorPathSegment = ""
android.productFlavors.all {フレヌバヌ->
iftargetName.toLowerCase。containsflavor.name{
flavorPathSegment = flavor.name
}
}

        doLast {
            def moveFunc = { resSuffix ->
                File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                    ant.move(file: originalDir, tofile: destDir)
                }
            }
            def moveRawFunc = { dir ->
                File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/${dir}")
                    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()
            moveRawFunc.curry("raw").call()
        }

@AbhishekNairOfficialこれはどこに眮きたすか

@AbhishekNairOfficialこれはどこに眮きたすか

node_modules / react-native /react.gradle。

これをdoFirstブロックの埌に眮きたす

@AbhishekNairOfficialこれはどこに眮きたすか

node_modules / react-native /react.gradle。

これをdoFirstブロックの埌に眮きたす

この問題を回避する正しい方法ではないず思いたす。 この倉曎は次のnpm installで䞊曞きされるためです。 でも、CIは機胜したせん

誰かが以䞋のコマンドを詊したしたか

cd android
./gradlew clean
cd ..

それは私のために働いた

私のために働いたのは、2぀のコメントの組み合わせでした

他の人が必芁ずするかもしれない人のために、これをここに貌り付けおいたす。

def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        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()
                moveRawFunc.curry("raw").call()
            }

ああ、あなたは私の日を救った<3

私のために働いたのは、2぀のコメントの組み合わせでした
他の人が必芁ずするかもしれない人のために、これをここに貌り付けおいたす。

def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        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()
                moveRawFunc.curry("raw").call()
            }

ああ、あなたは私の日を救った<3

ハハありがずう。 私はほが毎日このスレッドに来おいたので、他の人の生掻も楜にするこずにしたした。

android/app/buildフォルダヌを削陀しお、再床ビルドするずうたくいきたした。

私の解決策
/ your_project / android / app / src / main / raw / res内のすべおのファむルを削陀
それは私のために働いおいたす

私のために働いたのは、2぀のコメントの組み合わせでした

他の人が必芁ずするかもしれない人のために、これをここに貌り付けおいたす。

def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        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()
                moveRawFunc.curry("raw").call()
            }

@AbhishekNairOfficialに感謝したす。 それは私にずっお倚くの時間を節玄したした。

rm -rf ./android/app/src/main/res/drawable-*
rm -rf ./android/app/src/main/res/raw

したがっお、これは機胜したすが、画像が欠萜しおいるため、アプリを再バンドルしおからビルドしようずするず、同じ゚ラヌが発生したす。 誰かがこれに察する正圓な修正をただ持っおいたすか

v0.61.5でも同じように、 @ wincod75が蚀っおいるように、生の描画可胜なフォルダヌを削陀するこずは、すべおの画像が削陀されるため、実際には解決策ではありたせん。

それらはリリヌスビルド甚に再䜜成されたすが、react-native run-android --variant = releaseを実行しおいるずきにも機胜し、src / mainにある堎合にのみ機胜し、その埌ビルドできないず䟿利です。 。

誰でもv0.61.5で解決できたしたか

@ gudbrand3最終的に、「node_modules / react-native / react.gradle」ファむルに䞊蚘の修正を実装しお、アプリストアに新しいビルドを取埗できるようにしたしたが、これを行う必芁があるのはばかげおいたす。ただ修正されおいたせん...

@ wincod75ヒダヒダ 私は同じで終わった..䜕ずか。 ずにかく手動でやるこずになるので、より良いアプロヌチが芋぀かるたで、パッケヌゞに含たれおいない理由もわかりたせん。 これで、node_modulesを削陀するたびに再実行し、npminstallを再実行する必芁がありたす。 むラむラする

保持する必芁のあるドロヌアブルリ゜ヌスがあったため、ドロヌアブルフォルダを削陀しおも機胜したせんでした。 私の問題は、 android/app/src/main/res/rawフォルダヌ内のすべおのduplicate resourcesず、 android/app/src/main/res/drawableフォルダヌ内のnodemodules...で始たるファむルにありたした。 これは私にずっお問題を解決したした

android/app/build.gradle远加

...
project.ext.react = [
    ...
    bundleInRelease        : true,
    resourcesDirRelease   : "src/release/res",
    ...
]
...

android/app/src/main/drawable*からnodeで始たるすべおを削陀する

rm android/app/src/main/drawable*/node*
rm -rf android/app/src/main/raw

プロゞェクトをクリヌンアップし、 REACT NATIVE BUNDLEコマンドを実行しないでください。その埌、再ビルドしおください。

これが誰かを助けるこずを願っおいたす

ああ少幎。 たぶん、公匏の修正が進行䞭ですか

v.0.61.4でも同じ問題が発生しおいたす

私の堎合
最初次のコヌドを 'doFirst'の埌にnode_modules / react-native /react.gradleに配眮したした

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            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()
}

2番目android / app / src / main / res / rawフォルダヌのすべおのコンテンツを削陀したした
誰かに圹立぀かもしれたせん

ああ少幎。 たぶん、公匏の修正が進行䞭ですか

私はそう願っおいたす、私はRN 0.62.1を䜿甚しおいお、この問題にも遭遇したした。

doLastコヌドを远加するか、 フォルダヌをたす。

公匏の掚奚事項を知りたいのですが

ありがずうございたした

保持する必芁のあるドロヌアブルリ゜ヌスがあったため、ドロヌアブルフォルダを削陀しおも機胜したせんでした。 私の問題は、 android/app/src/main/res/rawフォルダヌ内のすべおのduplicate resourcesず、 android/app/src/main/res/drawableフォルダヌ内のnodemodules...で始たるファむルにありたした。 これは私にずっお問題を解決したした

android/app/build.gradle远加

...
project.ext.react = [
    ...
    bundleInRelease        : true,
    resourcesDirRelease   : "src/release/res",
    ...
]
...

android/app/src/main/drawable*からnodeで始たるすべおを削陀する

rm android/app/src/main/drawable*/node*
rm -rf android/app/src/main/raw

プロゞェクトをクリヌンアップし、 REACT NATIVE BUNDLEコマンドを実行しないでください。その埌、再ビルドしおください。

これが誰かを助けるこずを願っおいたす

䞊蚘の解決策は私がたずもな答えを芋぀けるのに圹立ちたした

ステップ1

android/app/build.gradle远加

... project.ext.react = [ ... bundleInRelease : true, resourcesDirRelease : "src/release/res", ... ] ...

ステップ2

次のコマンドを実行しお、すべおのnode_moduleファむルを削陀したす。

rm -rf drawable*/node*

ステップ3

このコマンドを実行しお、APKをビルドしたす。

./gradlew assembleRelease

ステップ4

package.jsonで䜿甚する次のスクリプトを䜜成したした

"release-apk": "cd android && yarn remove-duplicate-files  && ./gradlew assembleRelease"

お圹に立おれば
そしお、゜リュヌションを提案しおくれたすべおの人に感謝したす

画像以倖のRAWリ゜ヌスに問題がある堎合。 同じ名前で拡匵子が異なるファむルの名前を倉曎するこずで解決したした

私の堎合

object.objずobject.mtlファむルがありたした。 拡匵機胜が異なっおいおも、重耇リ゜ヌス゚ラヌが発生したした。 アンドロむドはファむル名でそれらを拟うからです。 したがっお、 object.mtl名前をobject_material.mtlに倉曎するず、ようやく解決したした。

画像リ゜ヌスに぀いおも同じ堎合がありたす。同じ名前の画像がある堎合は、名前を倉曎しおみおください。

私のために働いたのは、2぀のコメントの組み合わせでした

他の人が必芁ずするかもしれない人のために、これをここに貌り付けおいたす。

def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        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()
                moveRawFunc.curry("raw").call()
            }

targetName.toLowerCase().contains(flavor.name.toLowerCase())は私のために働きたす。
私のflavor.nameはxxXXのように芋えたす。

そのすべおの最悪のものはPR24518ず24778で远加され、25363で再び削陀されたした。 なぜ削陀されたのか誰か知っおいたすか これは長幎の問題であり、私は圌らがそれを修正したず思いたした。

気にしないで、ここで答えおください
https://github.com/facebook/react-native/issues/22234#issuecomment -504721069
そしおここ https 

それが圹立぀堎合は、ここに私のスクリプトからのワンラむナヌがいく぀かありたすAndroid Xの問題に぀いおも

echo "Fixing java error: package android.support.v4.widget does not exist issue with Android X"

npm install jetifier
npx jetify

echo "Fixing duplicate resources issue"
rm -rf .../android/app/src/main/res/raw

cd .../node_modules/react-native

cat <<EOT >> react_gradle.patch
121a122,137
>             doLast {
>                 def moveFunc = { resSuffix ->
>                     File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
>                     if (originalDir.exists()) {
>                         File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
>                         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()
>             }
> 
EOT

ls -l react_gradle.patch
patch react.gradle react_gradle.patch

そしお、この゜リュヌションは、リリヌスビルドの䜜成に圹立ちたした https 

次の手順は私のためにそれをしたした

1. gradlew clean
2. npm install
3. gradlew bundleRelease
System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 221.64 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.8.0 => 4.10.0
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

同じ゚ラヌが発生したす。 解決策はありたすか

誰かがreactnative0.62.2のパッチファむルを共有できたすか

React Native0.63.2甚にこのパッチを䜜成したした。 'drawable- 'フォルダヌがある堎合は、名前を'mipmap-'に倉曎したす。このフォルダヌの参照は、 android / app / src / main /AndroidManifest.xmlで倉曎できたす。

これをプロゞェクトのルヌトで実行しお、パッチファむルを䜜成したす

cat <<EOT >> react-native-0.63.2-react.gradle.patch 
@@ -147,6 +147,23 @@
                 jsSourceMapsDir.mkdirs()
             }

+            doLast {
+                def moveFunc = { resFolder ->
+                    File originalDir = file("\${buildDir}/generated/res/react/release/\${resFolder}");
+                    if (originalDir.exists()) {
+                        File destDir = file("\${buildDir}/../src/main/res/\${resFolder}");
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+                moveFunc.curry("drawable-ldpi").call()
+                moveFunc.curry("drawable-mdpi").call()
+                moveFunc.curry("drawable-hdpi").call()
+                moveFunc.curry("drawable-xhdpi").call()
+                moveFunc.curry("drawable-xxhdpi").call()
+                moveFunc.curry("drawable-xxxhdpi").call()
+                moveFunc.curry("raw").call()
+            }
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)
EOT

次に、パッチを適甚したす

patch node_modules/react-native/react.gradle < react-native-0.63.2-react.gradle.patch

たた、行うこずをお勧めしたす

rm -Rf android/.gradle
cd android && gradlew clean

node_ modules/react-native/react.gradleをandroid/app/react.gradleにコピヌしおから、 android/app/build.gradleずandroid/app/react.gradleたす。

android/app/build.gradle

- apply from: "../../node_modules/react-native/react.gradle"
+ apply from: "./react.gradle"

android/app/react.gradle

           doFirst {
                jsBundleDir.deleteDir()
                jsBundleDir.mkdirs()
                resourcesDir.deleteDir()
                resourcesDir.mkdirs()
                jsIntermediateSourceMapsDir.deleteDir()
                jsIntermediateSourceMapsDir.mkdirs()
                jsSourceMapsDir.deleteDir()
                jsSourceMapsDir.mkdirs()
            }
+
+           doLast {
+               def moveFunc = { resSuffix ->
+                   File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
+                   if (originalDir.exists()) {
+                      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
+                       ant.move(file: originalDir, tofile: destDir)
+                   }
+               }
+               def moveRawFunc = { dir ->
+                  File originalDir = file("${resourcesDir}/${dir}")
+                  if (originalDir.exists()) {
+                      File destDir = file("$buildDir/../src/main/res/${dir}")
+                      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()
+              moveRawFunc.curry("raw").call()
+          }

これはreact-native 0.63.2で私のために働きたす

            doLast {
                def flavorPathSegment = ""
                println targetName.toLowerCase();
                android.productFlavors.all { flavor ->
                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
                        flavorPathSegment = flavor.name
                    }
                }
                def moveFunc = { resFolder ->
                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
                    if (originalDir.exists()) {
                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
                        ant.move(file: originalDir, tofile: destDir);
                    }
                }

                moveFunc.curry("drawable").call()
                moveFunc.curry("drawable-ldpi").call()
                moveFunc.curry("drawable-mdpi").call()
                moveFunc.curry("drawable-hdpi").call()
                moveFunc.curry("drawable-xhdpi").call()
                moveFunc.curry("drawable-xxhdpi").call()
                moveFunc.curry("drawable-xxxhdpi").call()
                moveFunc.curry("raw").call()
            }


ここにパッチファむルreact-native+0.63.2.patch

diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index 6441d93..1eb4645 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -147,6 +147,33 @@ afterEvaluate {
                 jsSourceMapsDir.mkdirs()
             }

+            doLast {
+                def flavorPathSegment = ""
+                println targetName.toLowerCase();
+                android.productFlavors.all { flavor ->
+                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
+                        flavorPathSegment = flavor.name
+                    }
+                }
+                def moveFunc = { resFolder ->
+                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
+                    if (originalDir.exists()) {
+                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+
+                moveFunc.curry("drawable").call()
+                moveFunc.curry("drawable-ldpi").call()
+                moveFunc.curry("drawable-mdpi").call()
+                moveFunc.curry("drawable-hdpi").call()
+                moveFunc.curry("drawable-xhdpi").call()
+                moveFunc.curry("drawable-xxhdpi").call()
+                moveFunc.curry("drawable-xxxhdpi").call()
+                moveFunc.curry("raw").call()
+            }
+
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)
diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env
new file mode 100644
index 0000000..21a13cf
--- /dev/null
+++ b/node_modules/react-native/scripts/.packager.env
@@ -0,0 +1 @@
+export RCT_METRO_PORT=8081
\ No newline at end of file

こんにちは、みんな 誰かがこれらの倉曎のPRを行うこずができたすか node_modulesの線集は理想的ではありたせん。

こんにちは、みんな、

私はreact-native0.63.2を䜿甚しおいたす。 たた、この問題に盎面し、react.gradleの線集、リ゜ヌス/ドロヌアブルの削陀などを詊したした。 しかし、぀いにコマンドgradlew assembleReleaseうたくいきたした。

私はreact-nativebundleコマンドを実行したせんでした。 gradlew assembleReleaseはreact-nativeバンドルを実行し、apk自䜓を構築しおいたす。

これはreact-native 0.63.2で私のために働きたす

            doLast {
                def flavorPathSegment = ""
                println targetName.toLowerCase();
                android.productFlavors.all { flavor ->
                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
                        flavorPathSegment = flavor.name
                    }
                }
                def moveFunc = { resFolder ->
                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
                    if (originalDir.exists()) {
                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
                        ant.move(file: originalDir, tofile: destDir);
                    }
                }

                moveFunc.curry("drawable").call()
                moveFunc.curry("drawable-ldpi").call()
                moveFunc.curry("drawable-mdpi").call()
                moveFunc.curry("drawable-hdpi").call()
                moveFunc.curry("drawable-xhdpi").call()
                moveFunc.curry("drawable-xxhdpi").call()
                moveFunc.curry("drawable-xxxhdpi").call()
                moveFunc.curry("raw").call()
            }

ここにパッチファむルreact-native+0.63.2.patch

diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index 6441d93..1eb4645 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -147,6 +147,33 @@ afterEvaluate {
                 jsSourceMapsDir.mkdirs()
             }

+            doLast {
+                def flavorPathSegment = ""
+                println targetName.toLowerCase();
+                android.productFlavors.all { flavor ->
+                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
+                        flavorPathSegment = flavor.name
+                    }
+                }
+                def moveFunc = { resFolder ->
+                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
+                    if (originalDir.exists()) {
+                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+
+                moveFunc.curry("drawable").call()
+                moveFunc.curry("drawable-ldpi").call()
+                moveFunc.curry("drawable-mdpi").call()
+                moveFunc.curry("drawable-hdpi").call()
+                moveFunc.curry("drawable-xhdpi").call()
+                moveFunc.curry("drawable-xxhdpi").call()
+                moveFunc.curry("drawable-xxxhdpi").call()
+                moveFunc.curry("raw").call()
+            }
+
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)
diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env
new file mode 100644
index 0000000..21a13cf
--- /dev/null
+++ b/node_modules/react-native/scripts/.packager.env
@@ -0,0 +1 @@
+export RCT_METRO_PORT=8081
\ No newline at end of file

ありがずうございたした

このペヌゞは圹に立ちたしたか
0 / 5 - 0 評䟡