gpt4 book ai didi

android - Fabric 和 Crashlytics 不适用于 Bazel 构建

转载 作者:行者123 更新时间:2023-11-30 05:08:23 26 4
gpt4 key购买 nike

我正在构建一个 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

我如何正确集成 fabric 和 crashlytics 以便它们在 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")]

最佳答案

您现在可以使用 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

关于android - Fabric 和 Crashlytics 不适用于 Bazel 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54144989/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com