Fabric和Crashlytics无法与Bazel构建配合使用

时间:2019-01-11 10:49:18

标签: android crashlytics bazel google-fabric crashlytics-android

我正在构建一个Android应用,该应用使用fabric-crashlytics记录设备中的所有崩溃。 这行特殊的代码:

    Crashlytics crashlyticsKit = new Crashlytics.Builder()
            .core(new CrashlyticsCore.Builder().disabled(false).build())
            .build();
    Fabric.with(this, crashlyticsKit);

与Bazel一起崩溃,但是,当我将此值设置为“ true”时。(即,我正在禁用Crashlytics),此应用程序的Bazel构建正常工作。 但是,如果我要构建一个普通的android应用程序,则不会崩溃,其值为“ true”或“ false”。但是,在Bazel中,构建完全在启动时崩溃。 错误是:

2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     |  | 
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     |  |
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     |  |
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .   \ |  | /
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .    \    /
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     \  /
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .      \/
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
    install an Android build tool and ask a team member to invite you to this app's organization.
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .      /\
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     /  \
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .    /    \
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .   / |  | \
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     |  |
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .     |  |
2019-01-11 15:55:55.808 19850-19850/com.sensennetworks.senanpr E/CrashlyticsCore: .
2019-01-11 15:55:55.812 19850-19850/com.sensennetworks.senanpr E/AndroidRuntime: FATAL EXCEPTION: main

我如何正确集成结构和崩溃解决方案以使其在Bazel中工作?

我在BUILD文件中的依赖项是:

 deps = [
        ":tensorflow_native_libs",
        "//tensorflow/contrib/lite/java:tensorflowlite",
        "@com_google_code_gson_gson//jar",
        "@com_mcxiaoke_volley_library//jar",
        #"@com_sun_mail_android_activation//jar",
        #"@com_sun_mail_android_mail//jar",
        gmaven_artifact("com.google.android.gms:play-services-location:aar:15.0.1"),
        gmaven_artifact("com.android.support:appcompat-v7:aar:26.1.0"),
        gmaven_artifact("com.android.support:design:aar:26.1.0"),
        gmaven_artifact("com.android.support:recyclerview-v7:aar:26.1.0"),
        gmaven_artifact("com.android.support:support-v4:aar:26.1.0"),
        gmaven_artifact("io.fabric.sdk.android:fabric:aar:1.3.17"),
        gmaven_artifact("com.crashlytics.sdk.android:crashlytics:aar:2.9.0"),
        #gmaven_artifact("com.crashlytics.sdk.android:crashlytics-core:aar:2.6.4"),
        gmaven_artifact("com.google.firebase:firebase-core:aar:15.0.2")]

1 个答案:

答案 0 :(得分:0)

您现在可以使用bazelbuild/tools_android通过crashlytics_android_library将Crashlytics直接集成到您的Bazel构建中。

load("@rules_maven//:defs.bzl", "artifact")
load("@tools_android//tools/crashlytics:defs.bzl", "crashlytics_android_library")
load("@tools_android//tools/googleservices:defs.bzl", "google_services_xml")

GOOGLE_SERVICES_RESOURCES = google_services_xml(
    package_name = "com.example.package",
    google_services_json = "google-services.json",
)

crashlytics_android_library(
    name = "crashlytics_lib",
    package_name = "com.example.package",
    build_id = "9dfea8fe-4d75-48a7-ba28-4ddb7fe74780",
    resource_files = GOOGLE_SERVICES_RESOURCES,
)

android_library(
    name = "crashlytics_deps",
    exports = [
        artifact("com.crashlytics.sdk.android:crashlytics"),
        artifact("io.fabric.sdk.android:fabric"),
    ],
)

android_library(
    name = "my_release_lib",
    srcs = glob(["src/main/**/*.java"]),
    manifest = "AndroidManifest.xml",
    resource_files = glob(["res/**/*"]),
    deps = [
        ":crashlytics_lib",
        ":crashlytics_deps", 
    ],
)

有关更多信息,请阅读https://github.com/bazelbuild/tools_android/blob/master/tools/crashlytics/README.md