Reputation: 929
I am tring to enable crashlytics for my NDK android app. Ive followed the the guide here. I got stuck on Step 2.
Step 2: Enable native symbol uploading To produce readable stack: traces from NDK crashes, Crashlytics needs to know about the symbols in your native binaries. Our Gradle plugin includes the uploadCrashlyticsSymbolFileBUILD_VARIANT task to automate this process (to access this task, make sure nativeSymbolUploadEnabled is set to true).
For method names to appear in your stack traces, you must explicitly invoke the uploadCrashlyticsSymbolFileBUILD_VARIANT task after each build of your NDK library. For example:
>./gradlew app:assembleBUILD_VARIANT\
app:uploadCrashlyticsSymbolFileBUILD_VARIANT
What does For method names to appear in your stack traces, you must explicitly invoke the uploadCrashlyticsSymbolFileBUILD_VARIANT task after each build of your NDK library.
mean? I also saw that they left a line with gradlew
. Is this a command on a command line? I am very lost. Can anyone help me achieve step 2?
Upvotes: 1
Views: 2980
Reputation: 57
Here's what I use to get symbols uploaded on every build. It works with both APK and App Bundle (AAB) builds and uses Gradle Task providers to avoid early configurations of Gradle tasks. It should automatically handle all application variants but silently ignores ones where required tasks are missing - for example, if symbols uploading option which actually just enables task generation (nativeSymbolUploadEnabled
) is not set. Don't know why Google cannot make this automatic - maybe they don't want to have their servers flooded with non-final builds.
afterEvaluate {
// Automatic NDK symbols uploading.
android.applicationVariants.configureEach { variant ->
final def variantName = variant.name.capitalize()
final def assembleTaskProvider = variant.assembleProvider
final def uploadCrashlyticsSymbolFileTaskName = "uploadCrashlyticsSymbolFile${variantName}"
final def bundleTaskName = "bundle${variantName}"
try
{
final def uploadCrashlyticsSymbolFileTaskProvider = project.tasks.named(uploadCrashlyticsSymbolFileTaskName)
if (uploadCrashlyticsSymbolFileTaskProvider != null)
{
// 'assemble***' task is used when building APK.
if (assembleTaskProvider != null)
{
assembleTaskProvider.configure { assembleTask ->
// This triggers after task completion
assembleTask.finalizedBy(uploadCrashlyticsSymbolFileTaskProvider)
}
uploadCrashlyticsSymbolFileTaskProvider.configure { uploadCrashlyticsSymbolFileTask ->
// This ensures ordering
uploadCrashlyticsSymbolFileTask.mustRunAfter(assembleTaskProvider)
}
}
// 'bundle***' task is used when building App Bundle (AAB).
try
{
final def bundleTaskProvider = project.tasks.named(bundleTaskName)
if (bundleTaskProvider != null)
{
bundleTaskProvider.configure { bundleTask ->
// This triggers after task completion
bundleTask.finalizedBy(uploadCrashlyticsSymbolFileTaskProvider)
}
uploadCrashlyticsSymbolFileTaskProvider.configure { uploadCrashlyticsSymbolFileTask ->
// This ensures ordering
uploadCrashlyticsSymbolFileTask.mustRunAfter(bundleTaskProvider)
}
}
}
catch (ignored) // Ignore all possible throws from 'named()' API.
{ }
}
}
catch (ignored) // Ignore all possible throws from 'named()' API.
{ }
}
}
Upvotes: 0
Reputation: 91
I was also at a lost, but finally understand.
This command should be like this.
At first, move to the directory
cd /YourProjectRootPath/proj.android/
You can find gradlew file in this directory.
Then execute gradlew to run two tasks.
Task1: assembleDebug or assembleRelease
Task2: uploadCrashlyticsSymbolFileDebug or uploadCrashlyticsSymbolFileRelease
the command is, (Example of debug)
./gradlew XXXXXX:assembleDebug XXXXXX:uploadCrashlyticsSymbolFileDebug
Please replace "XXXXXX" to your "app name".
If you don't know what is your app name, please run the command below.
./gradlew tasks --all
You can see all task names and can find these two tasks.
XXXXXX:assembleDebug XXXXXX:uploadCrashlyticsSymbolFileDebug
This "XXXXXX" is your "app name".
I don't know why Google describes such a complicated command using ">" and "\", but it's just a simple command,
./gradlew <TASK1> <TASK2>
Upvotes: 4
Reputation: 3845
When you add "nativeSymbolUploadEnabled true" to your gradle file like mentioned in Step1 this will instruct the gradle plugin to generate a new task with the format "uploadCrashlyticsSymbolFileBUILD_VARIANT" for each build type and architectures. Check this screenshot where I only have one build type "release" but also have three architectures. The tasks generated are:
To run these tasks, you will need to either execute the command in a terminal updated for the desired build variant, e.g.
>./gradlew app:assembleX86_64\
app:uploadCrashlyticsSymbolFileX86_64Release
Or manually calling those tasks in the gradle tab. They need to be executed in this order (first the assemble and then the uploadCrashlyticsSymbolFile...) to make sure the binaries have been created for Crashlytics to generate and upload the symbol files.
To answer your question: What does For method names to appear in your stack traces, you must explicitly invoke the uploadCrashlyticsSymbolFileBUILD_VARIANT task after each build of your NDK library.mean? Crashlytics will need the symbol files in order to convert the crash report into a readable stack trace with method names and line numbers.
Upvotes: 1