3

我正在尝试使用 Maven 将 Crashlytics 集成到我们的 Android 项目中。mvn clean package我已经设置了所有必需的插件,并且从命令行执行并完成了构建。运行从命令行构建的应用程序时 - 一切正常。

从 IntelliJ 运行应用程序时出现问题。

我认为Crashlytics执行 generate-resources 阶段时会发生所有魔术:

<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>

这个插件被添加到我的应用程序 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>

所以 - 问题是 - 当 IntelliJ 构建我的 APK 时,我如何执行这个目标?

应用程序运行时出现的错误:

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)

更新(07-24):

接受的答案应该可以工作,但是如果您重新下载并重新安装插件 - 它应该可以与本机 IntelliJ 构建器一起使用。虽然(今天)在 Ubuntu 机器上启动 IntelliJ 时它会崩溃。

4

1 回答 1

3

我能够让它工作的方法是进入右侧的 Maven Projects 选项卡,选择 Plugins,选择 crashlytics,然后在 GenerateResources 目标上右键单击并选择“Execute Before Make”

例子

于 2013-07-23T20:45:30.383 回答