我Aplication類gms.analytics.GoogleAnalytics - NoClassDefFoundError的
public class MyApplication extends Application {
private static final String PROPERTY_ID = "UA-XXXXXX-X";
public static int GENERAL_TRACKER = 0;
public enum TrackerName {
APP_TRACKER, // Tracker used only in this app.
GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg:
// roll-up tracking.
ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a
// company.
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public MyApplication() {
super();
}
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics
.newTracker(PROPERTY_ID)
: (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics
.newTracker(R.xml.global_tracker) : analytics
.newTracker(R.xml.ecommerce_tracker);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
}
app_tracker.xml
<string name="ga_trackingId">UA-XXXXXX-X</string>
<string name="ga_sampleFrequency">100</string>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<integer name="ga_sessionTimeout">-1</integer>
<screenName name="com.mobihouse.portabilidade.activities.HomeActivity_">HomeActivity</screenName>
global_tracker.xml
<integer name="ga_sessionTimeout">300</integer>
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<string name="ga_logLevel">verbose</string>
<!-- The screen names that will appear in reports -->
<screenName name="com.mobihouse.portabilidade.activities.HomeActivity_">HomeActivity Portabilidade</screenName>
<!-- The following value should be replaced with correct property id. -->
<string name="ga_trackingId">UA-XXXXXX-X</string>
在我的清單,我已經添加了這個:
<application
android:name="com.mobihouse.portabilidade.MyApplication"
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
我改變了我的PROPERTY_ID在這裏發表。
而問題是,登錄:
11-25 09:23:30.031: E/AndroidRuntime(8392): FATAL EXCEPTION: main 11-25 09:23:30.031: E/AndroidRuntime(8392): java.lang.NoClassDefFoundError: com.google.android.gms.analytics.GoogleAnalytics 11-25 09:23:30.031: E/AndroidRuntime(8392): at com.mobihouse.portabilidade.MyApplication.getTracker(MyApplication.java:45)
和:
11-25 09:23:29.992: I/dalvikvm(8392): Could not find method com.google.android.gms.analytics.Tracker.setScreenName, referenced from method com.mobihouse.portabilidade.activities.HomeActivity.onCreate
11-25 09:23:29.992: I/dalvikvm(8392): Could not find method com.google.android.gms.analytics.GoogleAnalytics.getInstance, referenced from method com.mobihouse.portabilidade.activities.HomeActivity.onStart
我搜索了幾個網站,但所有的解決方案沒有奏效,有人可以幫助我嗎?
我已經更新了谷歌播放服務的lib,我目前的版本= 21,根據亞行的經理,我想在安卓5.0來實現 - API 21
而且我已經把谷歌Play服務,因爲一個lib在我的項目中
具有u加入Google分析JAR文件庫folder..and在構建路徑 – Meenal 2014-11-25 11:46:33
@Meenal夏爾馬,我沒有信譽把圖像中加入它,所以我上傳我的庫的圖像: HTTP:// postimg 。org/image/xw6ddrq6z/ http://postimg.org/image/qnbo6x0qh/ 請看看plz。謝謝。 – 2014-11-25 12:18:29
也許您需要鏈接到Google Play服務作爲圖書館項目? – 2014-11-25 14:58:19