java.lang.NoClassDefFoundError:解析失败:Lcom / google / android / gms / analytics / GoogleAnalytics;

时间:2015-12-29 11:23:47

标签: android eclipse google-analytics google-play-services

我正在将Google Analytics v4集成到我的Eclipse项目中。我一直在尝试这个过去3-4天,但无法提出任何解决方案。我收到以下错误:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/analytics/GoogleAnalytics;

这是我的Application类:

    public class FindrApp extends Application {
        private static final String PROPERTY_ID = "UA-XXXXXXXX-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 FindrApp() {
        super();
    }

    public synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            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);
    }
}

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxxxx.xxxxxxxxxxxxx"
    android:versionCode="12"
    android:versionName="1.1.1">

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="20" />

    <permission
        android:name="com.xxxxxxxx.xxxxxxxxxx.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-permission
        android:name="com.xxxxxxxxxx.xxxxxxxxxxxx.permission.MAPS_RECEIVE"
        android:required="false" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:required="false" />
    <uses-permission
        android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_NETWORK_STATE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_FINE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_COARSE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE"
        android:required="false" />
    <uses-permission
        android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.VIBRATE"
        android:required="false" />
    <uses-permission
        android:name="com.google.android.c2dm.permission.RECEIVE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.GET_ACCOUNTS"
        android:required="false" />
    <uses-permission
        android:name="android.permission.WAKE_LOCK"
        android:required="false" />
    <uses-permission android:name="com.google.android.c2dm.intent.RECEIVE" />

    <!-- <permission
        android:name="fitness.enthusiast.permission.C2D_MESSAGE"
        android:protectionLevel="signature" >
    </permission>
    <uses-permission
        android:name="fitness.enthusiast.permission.C2D_MESSAGE"
        android:required="false" /> -->

    <permission
        android:name="com.sbw.mytestcm.permission.C2D_MESSAGE"
        android:protectionLevel="signature" >
    </permission>
    <uses-permission
        android:name="com.example.gcm.permission.C2D_MESSAGE"
        android:required="false"/>
    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-permission
        android:name="android.permission.CAMERA"
        android:required="false" />
    <uses-permission
        android:name="android.permission.READ_PROFILE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.READ_CONTACTS"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_NETWORK_STATE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:required="false" />
    <uses-permission
        android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_COARSE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_FINE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_COARSE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_FINE_LOCATION"
        android:required="false" />
    <uses-permission
        android:name="android.permission.CAMERA"
        android:required="false" />
    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:required="false" />
    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <!-- REMEMBER TO CHANGE APP NAME IN com.xxxxxxxxxx.xxxxxxxxxxxxxx.utils.AppRater.java -->
    <!--  -->
    <application
        android:name="com.xxxxxxxxxxx.xxxxxxxxxx.FindrApp"
        android:allowBackup="true"
        android:configChanges="keyboardHidden|orientation"
        android:icon="@drawable/icon_new"
        android:label="@string/app_name"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.NoTitleBar"
        android:windowSoftInputMode="stateHidden|adjustResize" >
        <activity
            android:name="com.xxxxxxxx.xxxxxxxxxxx.splash.Splash"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN"
                    android:screenOrientation="portrait" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="net.hockeyapp.android.UpdateActivity" />


        <!-- <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/> --> <!-- This key is for unsigned apk -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /><!-- This key is for signed apk -->
        <!-- Use this SHA1 key for signing the app -> 15:A3:A1:0A:C4:08:AE:A3:2C:33:F7:29:63:25:7F:66:70:6D:42:B3 -->
        <activity
            android:name="com.facebook.LoginActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/app_id" />

        <provider
            android:name="com.facebook.NativeAppCallContentProvider"
            android:authorities="com.facebook.app.NativeAppCallContentProvider592468157541502"
            android:exported="true" />

        <receiver android:name="com.xxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxx.fitcompanynewDesign.HelloFacebookBroadcastReceiver" >
            <intent-filter>
                <action android:name="com.facebook.platform.AppCallResultBroadcast" />
            </intent-filter>
        </receiver>


        <receiver
            android:name="com.xxxxxxxxxx.xxxxxxxxxxxxx.utils.gcm.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />

                <category android:name="com.xxxxxxxxxx.xxxxxxxxxxxxxx.fitcompanynewDesign" />
            </intent-filter>
        </receiver>

        <service android:name="com.xxxxxxxxxx.xxxxxxxxxxxxx.utils.gcm.GcmIntentService" />
        <meta-data
            android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker"/>

        <!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
         dispatching on non-Google Play devices -->
        <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver" android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
            </intent-filter>
        </receiver>
        <service android:name="com.google.android.gms.analytics.AnalyticsService"
             android:enabled="true"
             android:exported="false"/>

        <!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
         installation campaign reporting -->
        <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
             android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>
        <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

    </application>
</manifest>

错误发生在以下行:

GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

请帮帮我。提前谢谢!

0 个答案:

没有答案