我正在开发一个 android 库,我需要在其中使用 ReadableArray、WritableArray、ReadableMap,它们是 com.facebook.react:react-native 库的一部分。 我在库模块的 build.gradle 中添加了
com.facebook.react:react-native:0.61.5
,但是 gradle sync 失败并出现错误:Failed to resolve: com.facebook.react:react-native:0.61.5
。如何解决这个问题?
库模块的build.gradle
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'maven-publish'
}
android {
namespace 'com.example.cam_library'
compileSdk 33
defaultConfig {
minSdk 24
targetSdk 33
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
//react
implementation "com.facebook.react:react-native:0.61.5"
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.github.dev-ooo'
artifactId = 'Watch-Cam-Library'
version = '0.1.0'
}
}
}
}
项目的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
settings.gradle 项目
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
mavenLocal()
maven { url "https://maven.google.com" }
maven { url "https://repo1.maven.org/maven2" }
}
}
rootProject.name = "WatchCam"
include ':app'
include ':cam-library'