J'utilise Android Studio pour développer mon application et utilise gradle en créant quelques saveurs de produits. Les types de produits sont google, beta et lab.
Je souhaite uniquement intégrer Crashlytics dans une seule version du produit ( beta ), mais je rencontre un problème que je n’ai pas encore résolu.
Avec le fichier build.gradle actuel, je peux obtenir la version de compilation betaDebug et betaRelease pour la compilation, mais je ne parviens pas à obtenir la compilation des autres.
De plus, je n’ai pas pu faire reconnaître mon application par Crashlytics après le lancement réussi de la variante de construction betaDebug.
L'erreur que je reçois lorsque je change de version:
Gradle Running
Failed to complete Gradle exection.
Cause:
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.10-all.Zip'.
Voici mon fichier build.gradle:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'Android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
Android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
packageName "com.mcarrano.example"
}
buildTypes {
debug {
packageNameSuffix '.debug'
versionNameSuffix '-DEBUG'
}
release {
runProguard true
debuggable false
proguardFile 'proguard-rules.txt'
proguardFile getDefaultProguardFile('proguard-Android-optimize.txt')
}
}
productFlavors {
google {
packageName = Android.defaultConfig.packageName
versionName = Android.defaultConfig.versionName
}
beta {
packageName = Android.defaultConfig.packageName + ".beta"
versionName = Android.defaultConfig.versionName + "-BETA"
}
lab {
packageName = Android.defaultConfig.packageName + ".lab"
versionName = Android.defaultConfig.versionName + "-LAB"
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
Java.srcDirs = ['src/main/Java']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
google {
Java.srcDirs = ['src/google/Java']
}
beta {
manifest.srcFile 'src/beta/AndroidManifest.xml'
Java.srcDirs = ['src/beta/Java']
}
lab {
Java.srcDirs = ['src/lab/Java']
}
}
}
dependencies {
compile 'com.Android.support:support-v4:19.0.+'
compile 'com.Android.support:appcompat-v7:19.0.+'
betaCompile 'com.crashlytics.Android:crashlytics:1.+'
}
Voici la console Gradle lorsque l'application ne parvient pas à compiler:
Executing tasks: [:example:generateGoogleDebugSources]
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:example:preBuild
:example:preGoogleDebugBuild
:example:checkGoogleDebugManifest
:example:preBetaDebugBuild
:example:preBetaReleaseBuild
:example:preGoogleReleaseBuild
:example:preLabDebugBuild
:example:preLabReleaseBuild
:example:prepareComAndroidSupportAppcompatV71901Library UP-TO-DATE
:example:prepareGoogleDebugDependencies
:example:compileGoogleDebugAidl UP-TO-DATE
:example:compileGoogleDebugRenderscript UP-TO-DATE
:example:generateGoogleDebugBuildConfig UP-TO-DATE
:example:processGoogleDebugManifest UP-TO-DATE
:example:crashlyticsCleanupResourcesGoogleDebug
ERROR - Crashlytics Developer Tools error.
Java.lang.IllegalArgumentException: Invalid API key: null. Check the Crashlytics plugin to make sure that the application has been added successfully! Contact [email protected] for assistance.
at com.crashlytics.tools.Android.DeveloperTools.processProperties(DeveloperTools.Java:439)
at com.crashlytics.tools.Android.DeveloperTools.processArgs(DeveloperTools.Java:325)
at com.crashlytics.tools.Android.DeveloperTools.main(DeveloperTools.Java:285)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25)
at Java.lang.reflect.Method.invoke(Method.Java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.Java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.Java:233)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.Java:43)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.Java:88)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.Java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.Java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.Java:116)
at com.crashlytics.tools.gradle.CrashlyticsTaskBuilder.callDevtoolsWrappingRuntimeExceptions(CrashlyticsTaskBuilder.groovy:136)
at com.crashlytics.tools.gradle.CrashlyticsTaskBuilder.this$2$callDevtoolsWrappingRuntimeExceptions(CrashlyticsTaskBuilder.groovy)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25)
at Java.lang.reflect.Method.invoke(Method.Java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.Java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.Java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.Java:361)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.Java:877)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.Java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.Java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.Java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.Java:141)
at com.crashlytics.tools.gradle.CrashlyticsTaskBuilder$_crashlyticsCleanupResources_closure2.doCall(CrashlyticsTaskBuilder.groovy:57)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25)
at Java.lang.reflect.Method.invoke(Method.Java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.Java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.Java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.Java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.Java:877)
at groovy.lang.Closure.call(Closure.Java:412)
at groovy.lang.Closure.call(Closure.Java:425)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.Java:502)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.Java:483)
at org.gradle.api.internal.tasks.TaskStatusNagger$1.execute(TaskStatusNagger.Java:77)
at org.gradle.api.internal.tasks.TaskStatusNagger$1.execute(TaskStatusNagger.Java:73)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.Java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.Java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.Java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.Java:289)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.Java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.Java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.Java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.Java:33)
at org.gradle.internal.Factories$1.create(Factories.Java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.Java:198)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.Java:266)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.Java:135)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.Java:95)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.Java:31)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.Java:86)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.Java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.Java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.Java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.Java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.Java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.Java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.Java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.Java:64)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.Java:70)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.Java:30)
at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.Java:108)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:35)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.Java:45)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.Java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.Java:42)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.Java:24)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.Java:33)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.Java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.Java:71)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.Java:69)
at org.gradle.util.Swapper.swap(Swapper.Java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.Java:69)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.Java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.Java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.Java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.Java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.Java:45)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.Java:186)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.Java:49)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.Java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.Java:36)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.Java:39)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.Java:32)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.Java:125)
at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.Java:51)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.Java:155)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.Java:128)
at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.Java:116)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.Java:64)
at Java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.Java:895)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:918)
at Java.lang.Thread.run(Thread.Java:695)
usage: com.crashlytics.tools.Android.DeveloperTools
-androidManifest <androidManifestPath> Path to AndroidManifest.xml)
-androidRes <androidResPath> Path to Android resources (res/
folder)
-apiSecret <key> API Secret for the project
-buildEvent Notify Crashlytics that a build
event has occurred
-cleanupResourceFile Remove Crashlytics-generated
resource files
-generateResourceFile Generate Crashlytics-required
resources for the project.
-help Display command help.
-obfuscator <obfuscatorId> Optionally specify an obfuscator
vendor identifier for use with
storeDeobs.
-obVer <obfuscatorVersion> Optionally specify the
obfuscator vendor software
version for use with obfuscator.
-projectPath <path> Path to Android project root
-properties <propertiesarg> Properties file that overrides
the input properties
-quiet Silent command line output
-requireUploadSuccess Throw an exception if the
deobfuscation upload was not
successful
-resourceCheck Check if a resource file already
exists.
-storeDeobs <file> Store the specified
deobfuscation file in
preparation for upload.
-tool <toolarg> Name of the build tool
-uploadDeobs Attempt to upload deobfuscation
file(s) to Crashlytics servers.
-uploadDist <file>
-verbose Verbose command line output
-version <versionarg> Version of the build tool
Un grand merci à @bonnell pour avoir répondu à ma question par courrier électronique.
Ajoutez simplement ext.enableCrashlytics = false à toute construction/saveur dont vous ne voulez pas que Crashlytics fasse partie.
Pour une réponse complète qui résout mon problème:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'Android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
Android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
packageName "com.mcarrano.example"
}
buildTypes {
debug {
packageNameSuffix '.debug'
versionNameSuffix '-DEBUG'
}
release {
runProguard true
debuggable false
proguardFile 'proguard-rules.txt'
proguardFile getDefaultProguardFile('proguard-Android-optimize.txt')
}
}
productFlavors {
google {
packageName = Android.defaultConfig.packageName
versionName = Android.defaultConfig.versionName
ext.enableCrashlytics = false
}
beta {
packageName = Android.defaultConfig.packageName + ".beta"
versionName = Android.defaultConfig.versionName + "-BETA"
}
lab {
packageName = Android.defaultConfig.packageName + ".lab"
versionName = Android.defaultConfig.versionName + "-LAB"
ext.enableCrashlytics = false
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
Java.srcDirs = ['src/main/Java']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
google {
Java.srcDirs = ['src/google/Java']
}
beta {
manifest.srcFile 'src/beta/AndroidManifest.xml'
Java.srcDirs = ['src/beta/Java']
}
lab {
Java.srcDirs = ['src/lab/Java']
}
}
}
dependencies {
compile 'com.Android.support:support-v4:19.0.+'
compile 'com.Android.support:appcompat-v7:19.0.+'
betaCompile 'com.crashlytics.Android:crashlytics:1.+'
}
Avait un problème similaire: je devais désactiver les rapports de crashlytics dans les versions de débogage. La réponse de Michael ne m'a pas aidé: crashlytics a détruit l'application au démarrage après avoir ajouté ext.enableCrashlytics = false
à gradle configuration. Grâce à Github, j'ai trouvé une solution efficace:
build.gradle:
//...
Android {
buildTypes {
debug {
// enable crashlytics where you need
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
}
}
// ...
et classe d'application:
@Override
public void onCreate() {
//...
if ( BuildConfig.USE_CRASHLYTICS ) {
Crashlytics.start(this);
}
//...
}
MODIFIER
Selon le commentaire de slott : avec le tissu, vous devriez utiliser quelque chose comme ceci:
Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(!BuildConfig.USE_CRASHLYTICS).build()).build());
Pour ceux qui ont ce problème, mon problème était que la clé Crashlytics n'était pas définie dans mon fichier AndroidManifest.xml, par exemple:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:Android="http://schemas.Android.com/apk/res/Android"
package="com.example.myapp"
Android:versionCode="1"
Android:versionName="1.0">
<uses-permission Android:name="Android.permission.INTERNET"/>
<application Android:label="@string/app_name">
<activity Android:name="MyActivity" Android:label="@string/app_name" />
<meta-data Android:name="com.crashlytics.ApiKey"
Android:value="YOUR_API_KEY"/>
</application>
</manifest>
Si je veux partager la construction via crashlytics.
J'ai besoin d'installer le plugin Fabric et de m'enregistrer Après cela ..
**
déboguer { ext.enableCrashlytics = true }
**
après la construction de l'application, nous pouvons facilement partager via crashlytics
Merci
pour arrêter crashlytics pour les versions de débogage, j'ai ajouté le code ci-dessous après le code d'initialisation dans la première activité (de démarrage)
CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build(), new Crashlytics());