我已经安装了react-native-firebase和react-native-camera。当Play-services -vision停留在12.0.1
时,摄像头很好,但我遇到了这个错误(更新属性googleVisionBarcodeDetectorEnable 时出错)https://github.com/react-native-community/react-native-camera/issues/1844,需要升级到{ {1}}。
当15.0.2
从play-services-vision
升至15.0.2
时,似乎存在Google Play服务和Firebase冲突:
12.0.1
我尝试过Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[
15.0.1], but play-services-basement version was 16.0.1.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-messaging@17.3.4
-- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
-- Project 'app' depends onto com.google.firebase:firebase-core@16.0.6
-- Project 'app' depends onto com.google.android.gms:play-services-vision@15.0.2
,但它给了我com.google.android.gms:play-services-vision@16.2.0
错误。
最高达到17.0.2会引起exceed 64k methods
的版本冲突。
有人同时使用react-native-firebase和React-native相机吗?您能告诉我如何解决此版本冲突问题吗?
这是android / app / build.gradle中的依赖项
com.google.android.gms:play-services-basement
在android / build.gradle中扩展
dependencies {
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
implementation "com.android.support:exifinterface:${rootProject.ext.supportLibVersion}"
implementation ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
implementation project(':react-native-gesture-handler')
implementation project(':react-native-webview')
implementation project(':react-native-fast-image')
implementation project(':react-native-google-signin')
implementation project(':react-native-firebase')
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation ('com.google.android.gms:play-services-base:16.0.1')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true
}
implementation(project(':react-native-google-signin')) {
exclude group: "com.google.android.gms" // very important
}
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.facebook.react:react-native:+'
implementation project(':react-native-sqlite-storage')
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation 'com.facebook.fresco:animated-gif:1.10.0'
}
包装:
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "27.1.1"
}
答案 0 :(得分:7)
您需要更新gms:play-services-vision的版本。
implementation 'com.google.android.gms:play-services-vision:17.0.2'
答案 1 :(得分:2)
对于从Expo(v34)弹出到要使用Firebase的React-native项目中的任何人,如果您一直使用expo-barcode-scanner
,问题就出在其中,因为它使用的是旧版本的{{1 }}。
您有多种选择:
play-services-vision
删除为依赖项并使用另一个依赖项。expo-barcode-scanner
的{{1}} lib中删除视觉库的版本(已淘汰)答案 2 :(得分:-1)
您需要启用MultiDex,因为:
单个DEX中可以引用的方法总数 文件到65,536
并通过启用multidex,编译器会将额外的方法/功能放入另一个dex文件中。
执行以下步骤:
1-将MultiDex添加到build.gradle(模块文件):
implementation 'com.android.support:multidex:1.0.3'
2-克隆并构建项目
3-将multiDexEnabled = true添加到同一buil.gradle(Module)内
android {
....
defaultConfig {
...
multiDexEnabled true
...
}
}
启用MultiDex
4-将应用程序类添加到您的项目中并覆盖从MultiDexApplication而不是Application扩展它的应用程序类,例如:
java: public class MyMultiDexApplication extends MultiDexApplication { ... }
Kotlin : class MyMultiDexApplication : MultiDexApplication() { override fun onCreate() {
super.onCreate() } }
5-在Application Tag中将您的应用程序类名称添加到AndroidManifest.xml:
<application
android:name=".MyMultiDexApplication "
android:icon="@mipmap/ic_logo"
android:label="@string/app_name"
>
6-添加所需的依赖项,例如:
com.google.android.gms:play-services-vision@16.2.0
构建.gradle
7-重新构建并完成
有关更多信息的Google参考: enter link description here
答案 3 :(得分:-1)
为了避免在导入模块时发生这种情况,我的简便解决方法是
1)npm安装 2)运行安卓/运行ios 3)我收到相同的消息,有时没有消息 4)我转到node_modules / react-native-component-name并找到android / build.gradle文件,将compileSdkVersion和buildToolsVersion更改为我的版本(最新),并用加号替换所有依赖项
com.google.android.gms:play-services-vision:17.0.2 => com.google.android.gms:play-services-vision:+
这样,该模块将始终使用可用的最新库