react-native-background-job 加载依赖报错处理
加载依赖时报错信息
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.firebase:firebase-jobdispatcher:0.8.5.
原因:历史包很久不维护,很多地方已经下载不到
处理方式:
1、从其他地方下载包:https://mvnrepository.com/artifact/com.firebase/firebase-jobdispatcher/0.8.5
2、直接下载 firebase-jobdispatcher-0.8.5.aar
3、到node_modules 下 找到第三方库 react-native-background-job,创建libs 目录,把上面的 firebase-jobdispatcher-0.8.5.aar 放进去
4、修改 build.gradle 文件, 远程链接,改成本地加载
dependencies {
// compile 'com.firebase:firebase-jobdispatcher:0.8.5'
compile files('libs/firebase-jobdispatcher-0.8.5.aar')
compile 'com.facebook.react:react-native:+'
}
5、参考图:
6、build.gradle 文件参考
buildscript { repositories { maven{ url 'https://maven.aliyun.com/repository/google'} maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} maven{ url 'https://maven.aliyun.com/repository/public'} maven{ url 'https://maven.aliyun.com/repository/jcenter'} google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' } } apply plugin: 'com.android.library' def DEFAULT_COMPILE_SDK_VERSION = 27 def DEFAULT_BUILD_TOOLS_VERSION = '25.0.3' def DEFAULT_TARGET_SDK_VERSION = 27 android { compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION // Uncomment to develop with yarn link into node_modules // compileOptions.incremental = false defaultConfig { minSdkVersion 16 targetSdkVersion project.hasProperty('targetSdkVersion') ? project.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION versionCode 2 versionName "2.0" ndk { abiFilters "armeabi-v7a", "x86" } } lintOptions { warning 'InvalidPackage' } } repositories { maven{ url 'https://maven.aliyun.com/repository/google'} maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} maven{ url 'https://maven.aliyun.com/repository/public'} maven{ url 'https://maven.aliyun.com/repository/jcenter'} google() jcenter() mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } dependencies { compile files('libs/firebase-jobdispatcher-0.8.5.aar') compile 'com.facebook.react:react-native:+' }