java Crashlytics 错误 - 此应用依赖于 Crashlytics。请注册访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45839054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 08:56:04  来源:igfitidea点击:

Crashlytics error - This app relies on Crashlytics. Please sign up for access

javaandroidcrashlytics

提问by j2emanue

I have two build flavors in gradle but for some reason whenever i change the following flag to false i get the titled error message:

我在 gradle 中有两种构建风格,但由于某种原因,每当我将以下标志更改为 false 时,我都会收到标题为错误消息:

ext.enableCrashlytics = false

the error itself complete is below:

错误本身完整如下:

Process: com.mobile.myapp.staging, PID: 5439
java.lang.RuntimeException: Unable to create application com.mobile.myapp.UI.myappApplication: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: 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.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: 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.
at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:234)
at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:207)
at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44)
at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611)
at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43)
at io.fabric.sdk.android.Kit.initialize(Kit.java:69)
at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:440)
at io.fabric.sdk.android.Fabric.init(Fabric.java:384)
at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:342)
at io.fabric.sdk.android.Fabric.with(Fabric.java:313)
at com.mobile.myapp.UI.base.BaseApplication.setupExceptionHandling(BaseApplication.java:51)
at com.mobile.myapp.UI.myappApplication.onCreate(myappApplication.java:45)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)

And this is how I initialize crashlytics in my Application subclass:

这就是我在我的 Application 子类中初始化 crashlytics 的方式:

Fabric.with(this, new Crashlytics());

what i am trying to do is have control over whether or not a crashlytics can run or not per flavor. lets say i want flavor1 not to run crashlytics i thought i could use that gradle flag and set it to false. am i missing something ?

我想要做的是控制 crashlytics 是否可以按口味运行。假设我希望flask1 不运行crashlytics,我认为我可以使用该gradle 标志并将其设置为false。我错过了什么吗?

采纳答案by nimelorm

Addition to answer of Todd Burner

托德·伯纳( Todd Burner) 的回答的补充

Be carefull with BuildConfig.DEBUG. IDE can auto-import it from

小心使用BuildConfig.DEBUG. IDE 可以从

com.crashlytics.android.BuildConfig (= false)

instead of your app config

而不是您的应用程序配置

${app_package}.BuildConfig

UPDATE

更新

Providing an example on the request of j2emanue

提供一个关于j2emanue请求的例子

    ...
    import com.fiot.ot.BuildConfig             <- should be
    import com.crashlytics.android.BuildConfig <- my IDE automatically imported 

    fun initFabric(context: Context) {
        val core = CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()
        val kit = Crashlytics.Builder().core(core).build()
        Fabric.with(context, kit)
    }

Where com.fiot.otpackage name of my app

com.fiot.ot我的应用程序包名称

回答by DaoLQ

Maybe missing apply plugin fabric

也许缺少应用插件结构

I added this line on top of file app/build.gradleresolved my issues!

我在文件顶部添加了这一行app/build.gradle解决了我的问题!

apply plugin: 'io.fabric'

应用插件:'io.fabric'

回答by KGBird

Whenever I set

每当我设置

ext.enableCrashlytics = false

my app crashes with

我的应用程序崩溃了

io.fabric.sdk.android.services.concurrency.UnmetDependencyException

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.

What seems to work for me is that I have to disable automatic initialization of Crashlytics by adding this line to AndroidManifest.xml

似乎对我有用的是我必须通过将此行添加到 AndroidManifest.xml 来禁用 Crashlytics 的自动初始化

<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

Then I manually initialize Crashlytics in the onCreate() method of my Application subclass, use BuildConfig.DEBUG to decide whether to disable CrashlyticsCore, and call Fabric.with(). In fact, I no longer set

然后我在我的 Application 子类的 onCreate() 方法中手动初始化 Crashlytics,使用 BuildConfig.DEBUG 来决定是否禁用 CrashlyticsCore,并调用 Fabric.with()。事实上,我不再设置

ext.enableCrashlytics = false

at all. It all seems to work to me.

根本。这一切对我来说似乎都有效。

回答by Todd Burner

Todd from Fabric. You will get this error unless you also disable Fabric at run time.

来自织物的托德。除非您还在运行时禁用 Fabric,否则您将收到此错误。

    // Set up Crashlytics, disabled for debug builds
Crashlytics crashlyticsKit = new Crashlytics.Builder()
    .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
    .build();

// Initialize Fabric with the debug-disabled crashlytics.
Fabric.with(this, crashlyticsKit);

Check out this link for more details: https://docs.fabric.io/android/crashlytics/build-tools.html#disable-crashlytics-for-debug-builds

查看此链接了解更多详情:https: //docs.fabric.io/android/crashlytics/build-tools.html#disable-crashlytics-for-debug-builds

回答by Githithu Wambura

Make sure you add in

确保您添加

app.gradle

应用程序.gradle

apply plugin: 'io.fabric'

I also have

我也有

classpath 'io.fabric.tools:gradle:1.26.1'

in the

在里面

project gradle dependencies

项目gradle依赖

and add the Crashlytics api in the strings, signup in the Crashlytics Site

并在字符串中添加 Crashlytics api,在Crashlytics 站点中注册

回答by Pierre

For Xamarin Android (Fabric is Deprecated - EOL)

对于 Xamarin Android(不推荐使用结构 - EOL)

You need to have the following not to receive the above error:

您需要具备以下条件才不会收到上述错误:

  1. Include the NuGet packages:
    • Xamarin.Android.Crashlytics [by Microsoft]
    • Xamarin.Android.Crashlytics.Core [by Microsoft]
    • Xamarin.Android.Crashlytics.Beta [by Microsoft]
    • Xamarin.Android.Crashlytics.Answers [by Microsoft]
  2. Add this line in your AndroidManifest.xmlfile within <application>:

    <meta-data android:name="io.fabric.ApiKey" android:value="<FABRIC_API_KEY>" />

  3. Add this line in Resources/values/Strings.xmlresource file:

    <string name="com.crashlytics.android.build_id">15</string>

  4. Add this line in MainApplication.csor YourActivity.csin OnCreate():

    Fabric.Fabric.With(this, new Crashlytics.Crashlytics());

  1. 包括 NuGet 包:
    • Xamarin.Android.Crashlytics [由微软]
    • Xamarin.Android.Crashlytics.Core [由微软]
    • Xamarin.Android.Crashlytics.Beta [由微软]
    • Xamarin.Android.Crashlytics.Answers [由微软]
  2. 在您的AndroidManifest.xml文件中添加这一行<application>

    <meta-data android:name="io.fabric.ApiKey" android:value="<FABRIC_API_KEY>" />

  3. Resources/values/Strings.xml资源文件中添加这一行:

    <string name="com.crashlytics.android.build_id">15</string>

  4. MainApplication.csYourActivity.cs中添加这一行OnCreate()

    Fabric.Fabric.With(this, new Crashlytics.Crashlytics());

Your app should build and run past the initialization line without any issues. Only problem I have with it is the fact that there is one more place you need to update the Build version of your app everytime your release.

您的应用程序应该在没有任何问题的情况下构建并运行超过初始化行。我遇到的唯一问题是,每次发布时,您还需要在另一个地方更新应用程序的 Build 版本。



EDIT :

编辑 :

As far as I'm experiencing, the one value is required but not used at all. You do not actually have to increase the build number in Strings.xml, it picks up the build number from the app automatically, so you should be fine just to leave the value at: <string name="com.crashlytics.android.build_id">1</string>

就我所经历的而言,一个值是必需的,但根本没有使用。您实际上不必增加 中的内部版本号Strings.xml,它会自动从应用程序中获取内部版本号,因此您只需将值保留为: <string name="com.crashlytics.android.build_id">1</string>

If you experience it differently for Xamarin, please comment below.

如果您对 Xamarin 有不同的体验,请在下面发表评论。

回答by user3509903

In My case this got worked.

在我的情况下,这奏效了。

so, this is the top level project build.gradle

所以,这是顶级项目 build.gradle

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'java'
allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
}

and this is the build.gradle for app module

这是 app 模块的 build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "your application package name"
    minSdkVersion 10
    targetSdkVersion 22
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:22.0.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
    transitive = true;
}
}

and at last "clean build" and all was set for me.

最后“干净的构建”,一切都为我准备好了。