Question

I'm trying to integrate Crashlytics into our Android project with Maven. I have all required plugins set up and build executes and completes when mvn clean package from command line. When running app built from command line - it's all OK.

Problems occurs when running application from IntelliJ.

I think all Crashlytics magic happens when generate-resources phase is executed:

<plugin>
    <groupId>com.crashlytics</groupId>
    <artifactId>crashlytics-maven</artifactId>
    <version>1.0.3</version>
    <executions>
        <execution>
            <id>GenerateResources</id>
                <goals>
                    <goal>GenerateResources</goal>
                </goals>
        </execution>
        <execution>
            <id>CleanupResources</id>
            <goals>
                <goal>CleanupResources</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This plugin is added to my application pom.xml:

<build>
    <sourceDirectory>src</sourceDirectory>

    <plugins>
        <plugin>
            <groupId>com.crashlytics</groupId>
            <artifactId>crashlytics-maven</artifactId>
            <!-- full configuration declared in parent pom.xml -->
        </plugin>
        ... other plugins...
    <plugins>
</build>

So - question is - how do I execute this goal when IntelliJ builds my APK?

Error I get when application runs:

ERROR/AndroidRuntime(11626): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to create application lt.my.app.MyApplication: com.crashlytics.android.CrashlyticsMissingDependencyException: Crashlytics did not find a required runtime dependency. To configure your build environment, visit: http://www.crashlytics.com/api/v1/.../android/confirm/lt.my.app
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5085)
        at android.app.ActivityThread.access$1300(ActivityThread.java:162)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:158)
        at android.app.ActivityThread.main(ActivityThread.java:5777)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: com.crashlytics.android.CrashlyticsMissingDependencyException: Crashlytics did not find a required runtime dependency. To configure your build environment, visit: http://www.crashlytics.com/api/v1/.../android/confirm/lt.my.app
        at com.crashlytics.android.j.a(SourceFile:37)
        at com.crashlytics.android.Crashlytics.a(SourceFile:770)
        at com.crashlytics.android.Crashlytics.start(SourceFile:157)
        at com.crashlytics.android.Crashlytics.start(SourceFile:135)
        at lt.my.app.MyApplication.onCreate(MyApplication.java:32)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5082)

Update (07-24):

Accepted answer should work, but if you re-download and re-install plugin - it should work with native IntelliJ builder. Although (today) it crashes when launching IntelliJ on Ubuntu machine.

Was it helpful?

Solution

The way I was able to get it to work was by going into the Maven Projects tab on the right side, select Plugins, select crashlytics and on the GenerateResources goal right-click and select "Execute Before Make"

Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top