作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 this为二维码阅读器制作应用程序的库。当我单独制作演示时它可以工作,但当我将它与 OneSignal Sdk 一起使用时它不起作用。下面是我的 Gradle 代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "param.app.onesignaldemo"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "61053944-9916-41ae-baa0-1274a5660f6a",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:26.1.0'
// OneSignal SDK
compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
// OneSignal requires at least version 7.0.0 of GMS but the newest version is recommend.
// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:11.4.0'
// Required for geotagging
compile 'com.google.android.gms:play-services-location:11.4.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.github.kenglxn.QRGen:android:2.3.0'
compile project(':barCodeScanner')
compile project(path: ':barCodeScanner')
}
下面是我从 Activity 中调用二维码扫描器的代码。
final MaterialBarcodeScanner materialBarcodeScanner = new MaterialBarcodeScannerBuilder()
.withActivity(MainActivity.this)
.withEnableAutoFocus(true)
.withBleepEnabled(true)
.withBackfacingCamera()
.withText("Scanning...")
.withResultListener(new MaterialBarcodeScanner.OnResultListener()
{
@Override
public void onResult(Barcode barcode) {
txtvFriendsId.setText(barcode.rawValue);
}
})
.build();
materialBarcodeScanner.startScan();
日志中出现这样的错误。
Process: param.app.onesignaldemo, PID: 16153
java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzbgo
at com.google.android.gms.vision.barcode.BarcodeDetector$Builder.<init>(Unknown Source)
at com.edwardvanraak.materialbarcodescanner.MaterialBarcodeScannerBuilder.buildMobileVisionBarcodeDetector(MaterialBarcodeScannerBuilder.java:235)
at com.edwardvanraak.materialbarcodescanner.MaterialBarcodeScannerBuilder.build(MaterialBarcodeScannerBuilder.java:221)
at param.app.onesignaldemo.MainActivity.onCreate(MainActivity.java:58)
at android.app.Activity.performCreate(Activity.java:5966)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5532)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
我们将不胜感激任何帮助。
最佳答案
正如我在您的应用程序 build.gradle 中注意到的那样,声明的 google-play 服务是:
// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:11.4.0'
// Required for geotagging
compile 'com.google.android.gms:play-services-location:11.4.0'
然而,OneSignal 本身已经初始化了那些依赖项,
One signal build.gradle.您应该摆脱其中之一或在您的 build.gradle 中添加排除规则。
关于android - MaterialBarcodeScanner 在集成了 OneSignal Sdk 时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46639578/
我正在使用 this为二维码阅读器制作应用程序的库。当我单独制作演示时它可以工作,但当我将它与 OneSignal Sdk 一起使用时它不起作用。下面是我的 Gradle 代码: apply plug
从 Android Studio 3.1 升级到 3.2 后,同步失败并显示与 com.edwardvanraak:MaterialBarcodeScanner 依赖项相关的消息。 实现 'com.e
我是一名优秀的程序员,十分优秀!