【问题标题】:NoClassDefFoundError when upgrading Apptentive from version 1.7.3 version to 2.1.1 version将 Apptentive 从 1.7.3 版本升级到 2.1.1 版本时出现 NoClassDefFoundError
【发布时间】:2016-01-08 06:33:05
【问题描述】:

我正在尝试将 Apptentive 从 1.7.3 版本升级到最新的 2.1.1 版本。 但是,每当我调用方法
Apptentive.showMessageCenter(getActivity()),要启动 Apptentive 消息对话框,它会崩溃并为 ViewActivity 提供 NoClassDefFoundError。 日志如下:

java.lang.NoClassDefFoundError: com.apptentive.android.sdk.ViewActivity

01-08 11:30:41.837 E/AndroidRuntime(30049):在 com.apptentive.android.sdk.module.engagement.EngagementModule.launchInteraction(EngagementModule.java:75)

01-08 11:30:41.837 E/AndroidRuntime(30049):在 com.apptentive.android.sdk.module.engagement.EngagementModule.doEngage(EngagementModule.java:64)

01-08 11:30:41.837 E/AndroidRuntime(30049):在 com.apptentive.android.sdk.module.engagement.EngagementModule.engage(EngagementModule.java:53)

01-08 11:30:41.837 E/AndroidRuntime(30049):在 com.apptentive.android.sdk.module.engagement.EngagementModule.engageInternal(EngagementModule.java:31)

01-08 11:30:41.837 E/AndroidRuntime(30049):在 com.apptentive.android.sdk.ApptentiveInternal.showMessageCenterInternal(ApptentiveInternal.java:191)

01-08 11:30:41.837 E/AndroidRuntime(30049): at com.apptentive.android.sdk.Apptentive.showMessageCenter(Apptentive.java:635)

01-08 11:30:41.837 E/AndroidRuntime(30049): at com.apptentive.android.sdk.Apptentive.showMessageCenter(Apptentive.java:619)

我在 build.gradle 文件中的代码是:

compile 'com.apptentive:apptentive-android:2.1.1@aar'

而java代码是:

    Button writeUs = (Button) fitnessSyncDialog.findViewById(R.id.button_click_write_us);
writeUs.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Apptentive.showMessageCenter(getActivity());
    }
});

相同的代码适用于 1.7.3 版本。 有没有人遇到过这个问题,或者任何人都可以建议这里有什么问题吗?

提前感谢您提供任何宝贵的建议。

【问题讨论】:

  • 尝试清理并构建然后重新加载项目
  • 即使在清理它之后也会出现该错误。尽管在 1.7.3 中即使没有任何干净的构建它也能正常工作。

标签: android apptentive


【解决方案1】:

您可能没有在应用的清单中包含对 ViewActivity 的引用。例如:

<meta-data android:name="apptentive_api_key" android:value="YOUR_API_KEY_GOES_HERE"/>
  <activity android:name="com.apptentive.android.sdk.ViewActivity"
            android:theme="@style/ApptentiveTheme"/>

另一种可能性是您没有在 build.gradle 中包含对 Apptentive aar 的引用。例如:

repositories {
  jcenter()
}

dependencies {
  // These Google support libraries are required. Use the latest available.
  compile 'com.android.support:support-v4:23.0.1'
  compile 'com.android.support:appcompat-v7:23.0.1'
  compile 'com.android.support:cardview-v7:23.0.1'
  // The Apptentive SDK
  compile 'com.apptentive:apptentive-android:2.1.1@aar'
}

更多信息可以在这里找到http://www.apptentive.com/docs/android/integration/

【讨论】:

  • 嗨,Jake,感谢您的回复,但上面的元数据键存在。同样适用于修订版 1.7.3,无需任何更改。这是奇怪的行为。截至目前,我已将代码恢复为 1.7.3。但是任何建议都会有所帮助,以便可以在我的应用程序中使用新版本中的功能。
  • 嘿,Jake,我看到你在依赖项中使用了支持库 23.0.1。我正在使用支持库版本 22。那么最新的 apptentive 版本是否可能依赖于支持库 23+ 版本。如果是这样,可以与支持库 22 版本一起使用的 apptentive 版本是什么。此外,如果是这种情况,则错误似乎具有误导性。
  • 嗨,杰克,我发现是这种情况。最新的库仅适用于支持库 23+。
猜你喜欢
  • 2017-05-24
  • 2019-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多