-
-
Save jaisonfdo/962836bb865c9862d74ca2b0b18a7c6a to your computer and use it in GitHub Desktop.
This gist will help you to use Crashlytics like a pro.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
defaultConfig { | |
manifestPlaceholders = [crashlyticsApiKey: "514bec26d15bb8f67dc8129f0eda3cabf79fXXXX"] | |
} | |
buildTypes { | |
debug { | |
} | |
staging { | |
manifestPlaceholders = [crashlyticsApiKey: "848bec26d15bb8f67dc8129f0eda3cabf79fXXXX"] | |
} | |
release { | |
manifestPlaceholders = [crashlyticsApiKey: "427bec26d15bb8f67dc8129f0eda3cabf79fXXXX"] | |
} | |
} | |
} | |
<meta-data | |
android:name="io.fabric.ApiKey" | |
android:value="${crashlyticsApiKey}" /> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
defaultConfig { | |
buildConfigField 'Boolean', 'enableCrashlytics', 'false' | |
} | |
buildTypes { | |
debug { | |
buildConfigField 'Boolean', 'enableCrashlytics', 'false' | |
} | |
staging { | |
buildConfigField 'Boolean', 'enableCrashlytics', 'true' | |
} | |
release { | |
buildConfigField 'Boolean', 'enableCrashlytics', 'true' | |
} | |
} | |
} | |
if (BuildConfig.enableCrashlytics) | |
Fabric.with(this, new Crashlytics()); | |
android { | |
buildTypes { | |
debug { | |
// Disable fabric build ID generation for debug builds | |
ext.enableCrashlytics = false | |
... | |
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import com.crashlytics.android.Crashlytics; | |
public class CrashlyticsDemoActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_sample); | |
Crashlytics.setUserIdentifier("12345"); | |
Crashlytics.setUserEmail("jaisonfdo@gmail.com"); | |
Crashlytics.setUserName("Jaison"); | |
try { | |
String value=null; | |
int x=Integer.parseInt(value); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
Crashlytics.log("Test from sample activity"); | |
Crashlytics.logException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment