2016-01-08 149 views
2

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

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

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

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

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

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

01-08 11:30:41.837 E/AndroidRuntime(30049): at 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:[email protected]' 

和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版本。 有人遇到这个问题或任何人都可以提出什么问题可以在这里?

在此先感谢您提出宝贵建议。

+0

发现试图清理并生成然后重新加载项目 –

+0

即使在清洁它给人的错误之后。虽然在1.7.3的工作中,即使没有任何干净的构建。 –

回答

3

您可能未在应用的清单中包含对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:[email protected]' 
} 

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

+0

嗨杰克,感谢您的回应,但上面的元数据密钥在那里。此外,使用1.7.3修订版也没有任何变化。这是奇怪的行为。截至目前,我已经将我的代码恢复到1.7.3。但任何建议都会有所帮助,这样新版本中的功能就可以在我的应用程序中使用。 –

+0

嘿杰克,我看到你在依赖项中使用了支持库23.0.1。我正在使用支持库版本22.因此,最新的应用版本可能取决于支持库版本23+版本。如果是这样,什么是与支持库22版本一起工作的apptentive版本。此外,如果是这种情况,错误似乎是错误的。 –

+0

嗨杰克,我发现是这样的。最新的图书馆仅支持库23+。 –