-1
  1. bellow code is my build gradle dependency
  2. integrated as per developer console. but i got error when app open (get crash).
  3. when i run the app i get crash on home screen.
  4. give me any solution for this error.

apply plugin: 'com.android.application'

//apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 28
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    defaultConfig {
        applicationId "xxxxxxxxxxxx"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            packagingOptions {
                exclude 'META-INF/rxjava.properties'
            }
        }
    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:+'
    implementation 'io.reactivex:rxandroid:1.0.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.github.hotchemi:android-rate:1.0.1'

    implementation 'com.contentful.java:java-sdk:9.0.1'
    implementation 'com.jakewharton:butterknife:7.0.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    annotationProcessor 'com.contentful.vault:core:3.0.1'
    annotationProcessor 'com.contentful.vault:compiler:2.1.0'
    implementation 'com.contentful.vault:core:3.0.1'
    implementation 'com.romainpiel.shimmer:library:1.4.0@aar'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-analytics:10.2.4'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'


}

 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzac;
        at com.google.android.gms.internal.zzsc.zzan(Unknown Source)
        at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source)
        at com.monnfamily.libraryapp.BaseApplication.onCreate(BaseApplication.java:21)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
  1. the error got bellow
  2. i have integrated google analytics in my app but i got this error.
  3. Please give me any suggestion to clear this issue

public final class BaseApplication  extends Application {
    private static BaseApplication mInstance;
    private Activity mCurrentActivity = null;

    private static GoogleAnalytics sAnalytics;
    private static Tracker sTracker;

    @Override
    public void onCreate() {

        super.onCreate();
        sAnalytics = GoogleAnalytics.getInstance(this);  //error got here 
        mInstance = this;

    }

    /**
     * Gets the default {@link Tracker} for this {@link Application}.
     * @return tracker
     */
    synchronized public Tracker getDefaultTracker() {
        // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
        if (sTracker == null) {
            sTracker = sAnalytics.newTracker(R.xml.global_tracker);
        }

        return sTracker;
    }
Rahul Singh Chandrabhan
  • 2,531
  • 5
  • 22
  • 33
PRP
  • 101
  • 9

2 Answers2

0

Add latest version of google analytics in module level gradle file as follows :-

implementation 'com.google.android.gms:play-services-analytics:16.0.4'

use implementation instead of compile as compile is deprecated from gradle 4.0 and above

For l atest versions of Google Play Services

Saurabh Bhandari
  • 2,438
  • 4
  • 26
  • 33
  • 1
    thanks solve error,, but i didnt get active user count in analytics portal, how can i get that – PRP Dec 12 '18 at 09:04
0

Register your project on firebase console. Download the google-services.json file and put it in app folder and run the app. If it still does not work then try to remove the restriction from both the consoles and rerun the app.