diff --git a/android/app/build.gradle b/android/app/build.gradle index 2f881f4..e795770 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -147,17 +147,24 @@ android { } } } + packagingOptions { + //当项目中出现多个同名的so文件会编译异常,过滤多余的so文件 + pickFirst '**/libfbjni.so' + pickFirst '**/libc++_shared.so' + pickFirst '**/libjsc.so' + } } dependencies { - implementation project(':@react-native-community_async-storage') - implementation project(':react-native-music-control') - implementation project(':react-native-vector-icons') - implementation project(':react-native-gesture-handler') - implementation project(':react-native-video') + implementation project(path: ':@react-native-community_async-storage') + implementation project(path: ':react-native-music-control') + implementation project(path: ':react-native-vector-icons') + implementation project(path: ':react-native-gesture-handler') + implementation project(path: ':react-native-video') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.facebook.react:react-native:+" // From node_modules + implementation "org.webkit:android-jsc:+" } // Run this once to be able to run the application with BUCK diff --git a/android/build.gradle b/android/build.gradle index 3a1d305..405c063 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,23 +2,30 @@ buildscript { ext { + //在导入的项目中,如:react-native-music-control中有safeExtGet获取版本号 + //以下代码用于统一项目编译版本 buildToolsVersion = "28.0.3" - minSdkVersion = 16 + minSdkVersion = 21 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" + set('compileSdkVersion', compileSdkVersion) + set('buildToolsVersion', buildToolsVersion) + set('minSdkVersion', minSdkVersion) + set('targetSdkVersion', targetSdkVersion) } repositories { google() jcenter() } dependencies { - classpath("com.android.tools.build:gradle:3.4.0") + classpath "com.android.tools.build:gradle:3.4.3" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } +def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) allprojects { repositories { @@ -29,5 +36,17 @@ allprojects { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } + maven { + // Android JSC is installed from npm + url("$rootDir/../node_modules/jsc-android/dist") + } + } + configurations.all { + //低于0.65版本的‘react-native’需要加上这段代码, + //否则会出现类似:程序包com.facebook.react.common不存在 的错误 + resolutionStrategy { + // Remove this override in 0.65+, as a proper fix is included in react-native itself. + force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION + } } }