From ab83cfaacc860dd2d4fa808e879b80af42c81904 Mon Sep 17 00:00:00 2001 From: Li Zheng Date: Thu, 10 Nov 2022 14:32:19 +0800 Subject: [PATCH] =?UTF-8?q?React=E4=BD=BF=E7=94=A8=E8=AF=A6=E8=A7=A3.md:?= =?UTF-8?q?=20fix=20React-Native=20Android=20import=20from=20node=5Fmodule?= =?UTF-8?q?s=20directory=20does=20not=20working=20ref=20to=20https://githu?= =?UTF-8?q?b.com/facebook/react-native/issues/35204#issuecomment-130474022?= =?UTF-8?q?8=20caused=20by=20https://github.com/facebook/react-native/issu?= =?UTF-8?q?es/35210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...77\347\224\250\350\257\246\350\247\243.md" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git "a/i\344\270\273\350\247\202\347\232\204\344\275\223\351\252\214\346\226\271\345\274\217/t\345\277\253\344\271\220\347\232\204\344\275\223\351\252\214/\347\224\265\344\277\241/Tool/\347\274\226\347\250\213\350\257\255\350\250\200/JavaScript/React\344\275\277\347\224\250\350\257\246\350\247\243.md" "b/i\344\270\273\350\247\202\347\232\204\344\275\223\351\252\214\346\226\271\345\274\217/t\345\277\253\344\271\220\347\232\204\344\275\223\351\252\214/\347\224\265\344\277\241/Tool/\347\274\226\347\250\213\350\257\255\350\250\200/JavaScript/React\344\275\277\347\224\250\350\257\246\350\247\243.md" index 7232ca1..dfb7fc1 100644 --- "a/i\344\270\273\350\247\202\347\232\204\344\275\223\351\252\214\346\226\271\345\274\217/t\345\277\253\344\271\220\347\232\204\344\275\223\351\252\214/\347\224\265\344\277\241/Tool/\347\274\226\347\250\213\350\257\255\350\250\200/JavaScript/React\344\275\277\347\224\250\350\257\246\350\247\243.md" +++ "b/i\344\270\273\350\247\202\347\232\204\344\275\223\351\252\214\346\226\271\345\274\217/t\345\277\253\344\271\220\347\232\204\344\275\223\351\252\214/\347\224\265\344\277\241/Tool/\347\274\226\347\250\213\350\257\255\350\250\200/JavaScript/React\344\275\277\347\224\250\350\257\246\350\247\243.md" @@ -710,3 +710,78 @@ The installation of `react-native-unimodules` can ref to this commit [expo -> re ### [fixed `TypeError: Network request failed` when upload file to http not https with Android debug builds](https://github.com/facebook/react-native/issues/33217#issuecomment-1159844475) ### Fixed [x/mobile: Calling net.InterfaceAddrs() fails on Android SDK 30](https://github.com/golang/go/issues/40569#issuecomment-1190950966) if use GO on Android >= 11 + +### `$rootDir/../node_modules/react-native/android` as [React-Native Android import from node_modules directory does not working](https://stackoverflow.com/questions/50354939/react-native-android-import-from-node-modules-directory-does-not-working) +The 2022-11 issue [No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.](https://github.com/facebook/react-native/issues/35210) will cause one of Android build/run failures below: +``` +Could not resolve com.android.tools.lint:lint-gradle:26.5.3 +``` +``` +java.lang.IncompatibleClassChangeError: Found class com.facebook.react.uimanager.events.EventDispatcher, but interface was expected +``` +``` +Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.71.0-rc.0] ~/.gradle/caches/transforms-2/files-2.1/b7e5811cc2418a7984972c8ebe02d2c4/jetified-react-native-0.71.0-rc.0-debug/AndroidManifest.xml as the library might be using APIs not available in 16 +``` +``` +Could not download react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0): No cached version available for offline mode +``` +``` +/@minar-kotonoha/react-native-threads/android/src/main/java/com/reactlibrary/ReactContextBuilder.java:15: 错误: 找不到符号 +import com.facebook.react.bridge.NativeModuleCallExceptionHandler; +``` +Then fix below in `android/app/build.gradle` does not working anymore: +``` +implementation ("com.facebook.react:react-native:0.63.2") { force = true } +``` +``` +implementation "com.facebook.react:react-native:0.63.2!!" +``` +``` +android { + .... + configurations.all { + resolutionStrategy { + // failOnVersionConflict() + // force 'com.facebook.react:react-native:0.63.2' + substitude module('com.facebook.react:react-native:+') with module('com.facebook.react:react-native:0.63.2') + } + } +} +``` +``` +android { + .... + configurations.all { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + if (details.requested.group == 'com.facebook.react' + && details.requested.name == 'react-native') { + details.useVersion "0.63.2" + // details.useTarget group:'com.facebook.react', name:'react-native', version:"0.63.2" + // it.substitute it.module("com.facebook.react:react-native:+") with module("com.facebook.react:react-native:0.63.2") + } + } + } +} +``` +Finally fix below in `android/build.gradle` can work ref to https://github.com/facebook/react-native/issues/35204#issuecomment-1304740228 : + + allprojects { + repositories { + exclusiveContent { + filter { + includeGroup "com.facebook.react" + } + forRepository { + maven { + url "$rootDir/../node_modules/react-native/android" + } + } + } + } + ... + // actually now can remove below lines + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url("$rootDir/../node_modules/react-native/android") + } + }