I am trying to generate a KDoc documentation in an Android project. Following are the relevant files for adding this functionality.
build.gradle (root level):
buildscript {
...
ext.dokka_version = "0.10.1"
repositories {
...
maven { url "https://dl.bintray.com/kotlin/kotlin-eap/" }
}
dependencies {
...
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
}
}
...
build.gradle (Module:App)
...
apply plugin: 'org.jetbrains.dokka'
...
dokka {
outputFormat = 'html' // use 'javadoc' to get standard java docs
outputDirectory = "$buildDir/javadoc"
configuration {
includeNonPublic = false
skipEmptyPackages = true
skipDeprecated = true
reportUndocumented = true
jdkVersion = 8
}
}
Later, I am running ./gradlew dokka from the command line. But no output is getting generated. Following is what I get:
> Task :app:dokka
logging: loading modules: [java.se, jdk.accessibility, jdk.attach, jdk.compiler, jdk.dynalink, jdk.httpserver, jdk.jartool, jdk.javadoc, jdk.jconsole, jdk.jdi, jdk.jfr, jdk.jshell, jdk.jsobject, jdk.management, jdk.management.jfr, jdk.net, jdk.scripting.nashorn, jdk.sctp, jdk.security.auth, jdk.security.jgss, jdk.unsupported, jdk.unsupported.desktop, jdk.xml.dom, java.base, java.compiler, java.datatransfer, java.desktop, java.xml, java.instrument, java.logging, java.management, java.management.rmi, java.rmi, java.naming, java.net.http, java.prefs, java.scripting, java.security.jgss, java.security.sasl, java.sql, java.transaction.xa, java.sql.rowset, java.xml.crypto, jdk.internal.jvmstat, jdk.management.agent, jdk.jdwp.agent, jdk.internal.ed, jdk.internal.le, jdk.internal.opt]
No documentation for io.elektrifi.outageplanner.GettingStartedActivity (GettingStartedActivity.kt:9)
No documentation for io.elektrifi.outageplanner.GettingStartedActivity$<init>() (GettingStartedActivity.kt:9)
No documentation for io.elektrifi.outageplanner.GettingStartedActivity$onCreate(android.os.Bundle) (GettingStartedActivity.kt:10)
No documentation for io.elektrifi.outageplanner.LoginActivity (LoginActivity.kt:6)
No documentation for io.elektrifi.outageplanner.LoginActivity$<init>() (LoginActivity.kt:6)
No documentation for io.elektrifi.outageplanner.LoginActivity$onCreate(android.os.Bundle) (LoginActivity.kt:7)
No documentation for io.elektrifi.outageplanner.MainActivity (MainActivity.kt:17)
No documentation for io.elektrifi.outageplanner.MainActivity$<init>() (MainActivity.kt:17)
No documentation for io.elektrifi.outageplanner.MainActivity$onCreate(android.os.Bundle) (MainActivity.kt:18)
No documentation for io.elektrifi.outageplanner.RegisterActivity (RegisterActivity.kt:6)
No documentation for io.elektrifi.outageplanner.RegisterActivity$<init>() (RegisterActivity.kt:6)
No documentation for io.elektrifi.outageplanner.RegisterActivity$onCreate(android.os.Bundle) (RegisterActivity.kt:7)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity (SplashScreenActivity.kt:16)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity$<init>() (SplashScreenActivity.kt:16)
No documentation for io.elektrifi.outageplanner.SplashScreenActivity$onCreate(android.os.Bundle) (SplashScreenActivity.kt:19)
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
In fact, there is a small demo script in MainActivity. I am not sure why nothing is getting generated. Please let me know whether my configuration is correct. Also, it would be great to have a working configuration.
I am a newbie, so I did not realise it. The above configuration works. The KDoc comments must be above the class or function for which we are documenting. I was starting the commenting with /** and ending with */ at the very top of the Kotlin file (before import and package) and it didn't work.
Related
I have an android gradle project structure that looks like this
module1-aar
module2-aar
testapp-apk
Key facts
module2-aar depends on module1-aar
testapp-apk depends on module2-aar
JDK11
Gradle 7.4.2
Android gradle plugin 7.1.3
Without javadocs, gpg, signing, or publishing, everything builds just fine. App runs, everything is great.
When i started adding in tasks to generate javadocs, that's when everything went haywire. module1-aar will build and generate javadocs with no problem. module2-aar however always fails during the javadoc task.
Task is below. Most of it was borrowed from here How to generate javadoc for android library when it has dependencies which are also aar libraries?
project.task("javadoc", type: Javadoc) {
afterEvaluate {
configurations.all
.each {item ->
item.setCanBeResolved(true)
}
classpath += configurations.api
classpath += configurations.implementation
// Wait after evaluation to add the android classpath
// to avoid "buildToolsVersion is not specified" error
classpath += files(android.getBootClasspath())
// Process AAR dependencies
def aarDependencies = classpath.filter { it.name.endsWith('.aar') }
classpath -= aarDependencies
//fails here when an AAR depends on an AAR
aarDependencies.each { aar ->
// Extract classes.jar from the AAR dependency, and add it to the javadoc classpath
def outputPath = "$buildDir/tmp/aarJar/${aar.name.replace('.aar', '.jar')}"
classpath += files(outputPath)
// Use a task so the actual extraction only happens before the javadoc task is run
dependsOn task(name: "extract ${aar.name}").doLast {
extractEntry(aar, 'classes.jar', outputPath)
}
}
}
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += project.files(android.getBootClasspath())
classpath += configurations.implementation
classpath += fileTree(dir: project.buildDir.absolutePath + "/tmp/aarsToJars/")
classpath += files(project.buildDir.absolutePath + "/intermediates/compile_r_class_jar/release/R.jar")
classpath += files(project.buildDir.absolutePath + "/generated/source/buildConfig/release/release")
classpath += files(project.buildDir.absolutePath + "/generated/source/r/buildConfig/release/release")
destinationDir = file( project.buildDir.absolutePath + "/outputs/javadoc/")
failOnError true
options.charSet 'UTF-8'
options.docEncoding 'UTF-8'
options.encoding 'UTF-8'
options.addBooleanOption 'Xdoclint:none', true
exclude '**/BuildConfig.java'
exclude '**/R.java'
exclude '**/doc-files/*'
}
// Utility method to extract only one entry in a zip file
private def extractEntry(archive, entryPath, outputPath) {
if (!archive.exists()) {
throw new GradleException("archive $archive not found")
}
def zip = new java.util.zip.ZipFile(archive)
zip.entries().each {
if (it.name == entryPath) {
def path = new File(outputPath)
if (!path.exists()) {
path.getParentFile().mkdirs()
// Surely there's a simpler is->os utility except
// the one in java.nio.Files? Ah well...
def buf = new byte[1024]
def is = zip.getInputStream(it)
def os = new FileOutputStream(path)
def len
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len)
}
os.close()
}
}
}
zip.close()
}
//wires in the javadoc task to the normal build
tasks.named("build") { finalizedBy("generateJavadocJar") }
The error message i'm getting is the following
* What went wrong:
A problem occurred configuring project ':module2-aar'.
> Could not resolve all files for configuration ':module2-aar:implementation'.
> Could not resolve project :module1-aar.
Required by:
project :module2-aar
> Cannot choose between the following variants of project :module1-aar:
- debugRuntimeElements
- releaseRuntimeElements
All of them match the consumer attributes:
- Variant 'debugRuntimeElements' capability com.github.test:module1-aar:6.1.11-SNAPSHOT:
- Unmatched attributes:
- Provides com.android.build.api.attributes.AgpVersionAttr '7.1.3' but the consumer didn't ask for it
- Provides com.android.build.api.attributes.BuildTypeAttr 'debug' but the consumer didn't ask for it
- Provides com.android.build.gradle.internal.attributes.VariantAttr 'debug' but the consumer didn't ask for it
- Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
- Variant 'releaseRuntimeElements' capability com.github.test:module1-aar:6.1.11-SNAPSHOT:
- Unmatched attributes:
- Provides com.android.build.api.attributes.AgpVersionAttr '7.1.3' but the consumer didn't ask for it
- Provides com.android.build.api.attributes.BuildTypeAttr 'release' but the consumer didn't ask for it
- Provides com.android.build.gradle.internal.attributes.VariantAttr 'release' but the consumer didn't ask for it
- Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
I've been playing around with the gradle task a bit and it seems that the error message is generated anytime i attempt to iterate over the classpath of the module2-aar.
I have tried a number of other suggestions, like changing module2-aar's dependency declaration from
api project(':module2-aar')
to
api project(path:':module2-aar')
However that doesn't do anything
I also tried this:
api project(path: ':module1-aar', configuration: 'default')
While the above resolves the reported issue, it causes a compile issue whereby module2-aar doesn't appear to have module1-aar in the classpath during compile...and it seems to compile before module1-aar.
Unfortunately, the documentation for what configuration means when referencing an android project is a bit thin, or perhaps I'm looking in the wrong place. I'm not sure what other valid values are available.
Anyhow, I'm not sure what's wrong here other than I've spent way too much time on this.
I going to publish my solution to the problem of using "aar" files in javadoc. In the course of trying to solve the problem, I too, had been getting the same error that spy was referring to. That actually error means it can differentiate whether it should be using release or debug libraries. It seemed to me to be too futile to try and correct that issue, so instead, I took a different approach to solving what I think is essentially the same problem.
In my case, I have a project that contains multiple subprojects, and when I produce my javadoc documentation I wanted to produce a merged javadoc document, that consisted of just some of the subprojects (not all of the subprojects). As far as I know, this is not a capability, built into Android Studio. The current version of Android Studio(2021.2.1) seems to have problems producing javadoc documentation for android library modules. There are two issues:
1.) the javadoc classpath doesn't have the android bootclasses added. You get errors for referencing any android SDK method such as "Context", "Typeface", etc.
2.) the javadoc classpath doesn't get any AndroidX libraries added to it. Many of the AndroidX libraries are "aar" files. Android Studio(2021.2.1) does not handle aar files correctly when using javadoc.
My environment is similar to spy, except that I'm using android gradle plugin 7.2.0. I've created a custom javadoc task in the "app" module's build.gradle.kts script. My "app" module is an android application module. The code needs to be place in any module that contains either the plugin "com.android.application" or "com.android.library". Some of the modules that I produce the merged javadoc for are java libraries, and that's okay.
// create a custom configuration
val javadocDeps = configurations.create("javadocDeps")
// add javadoc dependencies that you need.
dependencies {
javadocDeps(project(":OsgiFramework"))
// note: I'm using a libs version catalog for the dependencies
// you can add hardwired dependencies if you prefer
javadocDeps (libs.androidx.appcompat)
javadocDeps (libs.androidx.fragment)
javadocDeps (libs.androidx.navigation.fragment)
javadocDeps (libs.androidx.navigation.ui)
javadocDeps (libs.androidx.constraint.layout)
}
// register the createCoreJavadoc task
// in my case, "gradlew app:createCoreJavadoc" creates the merged javadoc
tasks {
register<Javadoc>("createCoreJavadoc") {
setFailOnError(true)
val docDir: File = File(project.projectDir.parentFile.parentFile, "Doc/Core")
println("javadoc destination dir: " + docDir.absolutePath)
// set the location where the documentation is produced in
setDestinationDir(docDir)
// select the projects to produce merged javadoc for
var sourcepaths: FileCollection = project(":CoreInterfaces").files("src/main/java")
sourcepaths =
sourcepaths.plus(project(":CoreInternalInterfaces").files("src/main/java"))
sourcepaths = sourcepaths.plus(project(":CoreAndroidInterfaces").files("src/main/java"))
sourcepaths =
sourcepaths.plus(project(":CoreAndroidInternalInterfaces").files("src/main/java"))
sourcepaths = sourcepaths.plus(project(":OsgiInterface").files("src/main/java"))
sourcepaths =
sourcepaths.plus(project(":InstallPlanInterfaces_1_0_0").files("src/main/java"))
setSource(sourcepaths.asFileTree)
// fix the problem with the missing android bootclasses
android.bootClasspath.forEach{
classpath += fileTree(it)
}
// create a temporary directory for storing the "classes.jar" file contained in the *.aar files
val tmpDir:File = File(project.buildDir, "\\tmpAar\\")
if (tmpDir.exists()) tmpDir.delete()
tmpDir.mkdirs()
// add the javadoc dependencies
javadocDeps.forEach {
// I've got a custom class that allows me to treat jar or zip files and a file system
// you could replace this using spy's zip file extraction method
val zipFileSystem: com.phinneyridge.ZipFileSystem = ZipFileSystem(it.absolutePath,null)
if (it.name.endsWith(".aar")) {
// extract the classes.jar file from the aar file to the tmpDir
// renaming it to name of the aar file, but change the extension to jar
val tmpFile:File = File(tmpDir, it.name.replace(".aar", ".jar"))
zipFileSystem.extractEntry("classes.jar", tmpFile)
} else {
// for jar files, we just add it to the path
classpath += fileTree(it)
}
}
// now add the tmpDir files to the javadoc classpath
classpath += fileTree(tmpDir)
// for diagnosis purposes, we'll print the classpath.
// Notice that you have a lot more path entries then you have javadocDeps
println("classpath: " + classpath.asPath)
}
}
I understand that you have a project structure like this: app -> module2 -> module1.
Where -> means the dependency stream. So I deployed a project with that same dependency flow, but using gradle 7.0.2 (because that's what I'm currently using), and had no problem generating javadoc for module2 and module1
Basically it boils down to implementing this in every gradle of every module: https://stackoverflow.com/a/73096187/9902249
I hope it works for you.
I have Google this problem, but the results are not work for me.
The detail as following.
public final class App extends com.zhixin.wedeep.common.BaseApplication implements androidx.lifecycle.LifecycleOwner {
^
// Expected #HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
The App code.
#HiltAndroidApp
class App : BaseApplication(), LifecycleOwner {
#Inject
lateinit var service: EventService
private val mLifecycleRegistry = LifecycleRegistry(this)
}
This module gradle file.
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'dagger.hilt.android.plugin'
dependencies {
implementation rootProject.ext.dependencies["hilt-android"]
implementation rootProject.ext.dependencies["hilt-lifecycle-viewmodel"]
kapt rootProject.ext.kapt["hilt-compiler"]
kapt rootProject.ext.kapt["hilt-android-compiler"]
}
Who has ideas? Thanks!
I just hit this problem this morning. Do you have anything in your build.gradle that adds arguments to the annotationProcessOptions? For example:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
}
If so, try changing from "arguments =" to "arguments +=", as just using equals overwrites anything set previously.
EDIT: Looks like kotlin gradle plugin 1.5.21 solves the problem without using the bellow javacOptions.
UPDATE Kotlin and try again!
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
If you are not using Room and still get the error put this in the android block of build.gradle:
kapt {
javacOptions {
// These options are normally set automatically via the Hilt Gradle plugin, but we
// set them manually to workaround a bug in the Kotlin 1.5.20
option("-Adagger.fastInit=ENABLED")
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
It's a kapt bug on kotlin 1.5.20: https://github.com/google/dagger/issues/2684
SOLUTION 1 : Downgrade kotlin
If you are using kotlin-gradle-plugin:1.5.20 (in your project level build.gradle), downgrading it to 1.5.10 should fix the issue.
The issue will probably be fixed in the next versions, then you will upgrade to the new version.
SOLUTION 2 : Disable Gradle worker API
Add this line to your gradle.properties file:
kapt.use.worker.api=false
It will disable the gradle worker API.
It works for me, but as said in the documentation:
Using the worker API lets Gradle run independent annotation processing tasks from a single project in parallel, which in some cases significantly decreases the execution time.
So by disabling it, your build may be slowed down.
Just don't forget to add Hilt classpath dependency to your project level gradle file:
classpath "com.google.dagger:hilt-android-gradle-plugin:$versions.daggerHiltCoreVersion"
Define the specific version number instead of $versions.daggerHiltCoreVersion above.
And add plugin to your app level gradle:
apply plugin : 'dagger.hilt.android.plugin'
For later Gradle versions, add the plugin as follows
plugins {
id 'dagger.hilt.android.plugin'
}
Adding to sitatech's answer, I've also encountered this issue using kotlin-grade-plugin-1.5.20. The new 1.5.21 patch solved it for me.
Kotlin Grade Plugin v1.5.21 release notes: https://github.com/JetBrains/kotlin/releases/tag/v1.5.21
Issue in Jetbrains issue tracker: https://youtrack.jetbrains.com/issue/KT-47416
To backup #SteveC answer, when using Kotlin Gradle DSL is a bit different
We can't use either += or arguments = mapOf(). As stated in the official Dagger-Hilt documentation here & the github issue here regarding the docs as well
See below image for explanations:
arguments = mapOf() will call setArguments with this.arguments.clear(), thus will overwrite previous argument (in this case Hilt)
Workaround approach:
javaCompileOptions {
annotationProcessorOptions {
arguments(
mapOf(
"dagger.gradle.incremental" to "true",
"room.incremental" to "true"
)
)
}
}
Wrapping the arguments() as a functions instead of calling setter, it'll retain the previous arguments as well.
in my case, multi module in presentaion layer, I just removed :
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
in defaultConfig block
I'm trying to use dokka on my android project to generate kdoc.
But I have this error when I'm running the script 'modules:app [dokka]' :
Could not determine the dependencies of task ':app:dokka'.
kotlin.KotlinNullPointerException (no error message)
I added the following lines on my gradle files :
Project build.gradle
buildscript {
ext {
dokka_version = '0.9.18'
}
dependencies {
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
}
}
app build.gradle
plugins {
id 'org.jetbrains.dokka-android'
}
dokka {
outputFormat = 'html'
sourceDirs = files('src/main')
outputDirectory = "$buildDir/javadoc"
}
Could not determine the dependencies of task ':app:dokka'.
kotlin.KotlinNullPointerException (no error message)
The issue is that it's a multiplatform project. In the app level gradle file, I'm also applying the org.jetbrains.kotlin.multiplatform plugin. As described in the dokka github release page:
Experimental Kotlin Multiplatform support is scheduled for 0.9.19
Looks like there's no other solution than wait for the next release of dokka.
Edit: There's a workaround described on the kolinlang forum
dokka {
impliedPlatforms = ["common"] // This will force platform tags for all non-common sources e.g. "JVM"
kotlinTasks {
// dokka fails to retrieve sources from MPP-tasks so they must be set empty to avoid exception
// use sourceRoot instead (see below)
[]
}
sourceRoot {
// assuming there is only a single source dir...
path = kotlin.sourceSets.commonMain.kotlin.srcDirs[0]
platforms = ["common"]
}
}
We have programming an Android app and try to implement Crashlytics to our app.
We have different types of problem .
Version we used :
Android studio version :
3.3
Gradle version :
classpath 'com.android.tools.build:gradle:3.3.1'
Plugin :
Fabric for Android studio v4.3.0
Implementation :
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9') { transitive = true }
implementation('io.fabric.sdk.android:fabric:1.4.0#aar') { transitive = true }
gradle-wrapper.properties :
distributionUrl=https://services.gradle.org/distributions/gradle-5.2.1-all.zip
First Problem :
When we implement Crashlytics, you know that developers have 3 steps. We can not skip 2,3.steps. Because we have not compiled our application yet. We had two main errors:
Error 1:
This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
Error 2 :
E/CrashlyticsCore: The Crashlytics build ID is missing.This occurs when
Crashlytics tooling is absent from your app's build configuration.
Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
So, we had to be disabled "Debug Mod" to complete implementation of Crashlytic.
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
Fabric.with(this, crashlyticsKit); // Tod from Fabric suggested in stackoverflow
And implementation was completed.
But we do not want to do that. Because, when we have a crash, it does not any report to Crashlytics or Firebase. We also want to have debug mod’s crashes.
When we removed -> ....disabled(BuildConfig.DEBUG) - it shows again : Error 1, Error 2.
Second Problem :
In gradle ; apply plugin : ‘io.fabric’, we made the comment line, when we remove comments line, we have errors below :
Error 3 :
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Affected Modules: app
When we searched it, this error related to new android studio gradle. So we needed to make comment line “apply plugin: fabric.io” again.
There is no good solution about that.
To run application we can not remove:
new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build() : (due to Error1 Error2)
So we try to enable report different ways :
What have we try to add until here?
1. Enable in gradle :
buildTypes {
debug {
manifestPlaceholders = [crashlyticsEnabled: true]
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
manifestPlaceholders = [crashlyticsEnabled: false]
}
2. Enable in Manifest
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="true" />
3.Enable in ADB
adb shell setprop log.tag.Fabric DEBUG
adb shell setprop log.tag.CrashlyticsCore DEBUG
But still, Crashlytics or Firebase does not get any Debug Crash reports.
We have expecting your solutions.
I managed to get this fixed without adding android.debug.obsoleteApi=true in gradle.properties.
I basically connected 3 flavors to different Firebase projects using proper flavor configuration and the provided google-services.json file.
What your gradle file is missing comparing it to mine is this:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.google.gms:google-services:$google_services_version" // google-services plugin
classpath "io.fabric.tools:gradle:$fabric_tools_version"
}
apply plugin: "io.fabric"
And finally: implementation "com.google.firebase:firebase-crash:16.2.1"
I know Fabric is going to shut down this year, but by running the apps this way, they connected to the Firebase console with no problem whatsoever.
Regarding the flavor configuration, I downloaded three different json files (I have 3 flavors) and added them in the root directory of each flavor. For example:
flavor1:
assets
java
res
AndroidManifest
google-services.json (for flavor1)
flavor2:
assets
java
res
AndroidManifest
google-services.json (for flavor2)
And that's it. Hope this helps someone.
EDIT
So, as you guys may already know, Fabric is shutting down and Firebase Crashlytics is ready, making this answer deprecated.
Please check here so you can successfully update your app and avoid weird behaviors.
This also happens if you set ext.enableCrashlytics = false for a build variant but still try to call Fabric.with(context, Crashlytics()) in your app initialization code. ext.enableCrashlytics = false disables the build plugin (an optimization I made to make my debug builds faster) but then of course the build ID will be missing.
Today I migrated from Fabric Crashlytics to Firebase Crashlytics and encountered a fatal error that didn't keep me going. What I did was this:
In app-> build.gradle:
apply plugin: 'io.fabric'
dependencies {
implementation "com.google.firebase:firebase-core:17.2.0"
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
In general build.gradle:
buildscript {
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.31.2' // Crashlytics plugin
}
And of course download the json file from Firebase and insert it in the app folder.
After completing these simple steps, I received this error when I started the application
The Crashlytics build ID is missing. This occurs when Crashlytics
tooling is absent from your app's build configuration. Please review
Crashlytics onboarding instructions and ensure you have a valid
Crashlytics account.
I went to check that there wasn't any code that could call up old Fabric methods, and in fact I discovered that in app-> build.gradle I had this:
buildTypes {
debug {
minifyEnabled false
debuggable true
**ext.enableCrashlytics = false**
ext.alwaysUpdateBuildId = false
}
}
ext.enableCrashlytics = false certainly it was a method that referred to the old Fabric, so I removed this line and everything worked perfectly! I hope to help someone with this
just set apply plugin: 'io.fabric' in ur build.gradle (app)
In my case I was missing Crashlytics plugin:
apply plugin: 'com.google.firebase.crashlytics'
Put that line at the top of your module's build.gradle file e.g.
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
I faced the same issue when migrating from Fabric Crashlytics to Firebase Crashlytics, following steps fixed the issue for me
Clean your project
Update google-services.json file
Just add this line in your build.gradle (Project):
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
and this plugin in your build Gradle (app):
apply plugin: 'com.google.firebase.crashlytics'
I had the same problem in my app (Android Studio 3.4.1)
I fixed trough conecting to the Fabric Plugin. Creating an account and linking my app to it.
In my case i just update implementation 'com.google.firebase:firebase-core:16.0.9' to implementation 'com.google.firebase:firebase-core:17.0.1'
and added apply plugin: 'io.fabric' to my app level gradle. This solved Error 2 for me.
if you migrate from Fabric to Firebase please ensure you've called:
FirebaseApp.initializeApp(this)
in your Application onCreate().
No need any relation to Fabric anymore, just follow this guidance:
https://firebase.google.com/docs/crashlytics/get-started?platform=android
In My case, I hade two modules that used a different version of FireBase Crashlytics.
In My case, I miss this line: apply plugin: 'com.google.gms.google-services'
For reference, https://rnfirebase.io/crashlytics/android-setup
I had the same problem here and I fixed it by adding Fabric to Gradle
Here's my project Gradle file:
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I would like to prevent the usage of SNAPSHOT dependencies when building with Gradle a release version of an Android application or library.
How can I force the Gradle build to fail if there are any SNAPSHOT dependencies when building the release?
You could use a ResolutionStrategy.
See here for the API:
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
The below example was posted in the Gradle forums by Peter_Niederwieser
https://discuss.gradle.org/t/enforce-no-snapshot-dependencies-in-gradle/3851/2
configurations.all {
if (isRelease) {
resolutionStrategy.eachDependency { details ->
if (details.requested.version.endsWith("-SNAPSHOT")) {
throw new GradleException("found snapshot dependency")
}
}
}
}
The code must be placed either in the module build.gradle or in the "allprojects" section of the main build.gradle.