orhanobut / tracklytics

✔️ Annotation based tracking handler with aspect oriented programming
Apache License 2.0
429 stars 45 forks source link

Unable to include in the project #1

Closed manjunathc23 closed 7 years ago

manjunathc23 commented 8 years ago

Hi,

Can you help me solve this ?

Error:Could not find com.orhanobut.tracklytics:tracklytics-plugin:0.10.
Searched in the following locations:
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/orhanobut/tracklytics/tracklytics-plugin/0.10/tracklytics-plugin-0.10.pom
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/orhanobut/tracklytics/tracklytics-plugin/0.10/tracklytics-plugin-0.10.jar
    https://maven.fabric.io/public/com/orhanobut/tracklytics/tracklytics-plugin/0.10/tracklytics-plugin-0.10.pom
    https://maven.fabric.io/public/com/orhanobut/tracklytics/tracklytics-plugin/0.10/tracklytics-plugin-0.10.jar
Required by:

Thanks! Manju

orhanobut commented 8 years ago

could you show me build.gradle file please?

manjunathc23 commented 8 years ago

Sure,

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.orhanobut.tracklytics:tracklytics-plugin:0.8-SNAPSHOT'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.orhanobut.tracklytics'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    defaultConfig {
        applicationId "maverick.xxx.xxxx"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 29
        versionName "9.1.10"
    }

    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }

    buildTypes {

        debug {
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "Debug app"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
            // Enabling multidex support.
            multiDexEnabled true
        }

        release {
            shrinkResources true
            minifyEnabled true
            // Enabling multidex support.
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    tracklytics {
        mixpanel = false
        adjust = false
        fabric = false
        snowplow = false
        googleAnalytics = false
        crittercism = false
    }
    startTracklytics.execute()
}

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //Developer tools + Debug utils, unit test etc
    compile 'com.facebook.stetho:stetho:1.2.0'

    //Material Dialog
    compile('com.github.afollestad.material-dialogs:core:0.8.5.1@aar') {
        transitive = true
    }

    //About lib
    compile('com.mikepenz:aboutlibraries:5.3.3@aar') {
        transitive = true
    }

    //https://docs.fabric.io/android/fabric/third-party-kits.html
    //Trusted -- FABRIC, ANSWERS, MOPUB, Crashlytics
    compile('io.fabric.sdk.android:fabric:1.3.10@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.5.3@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
        transitive = true;
    }
    compile('com.mopub.sdk.android:mopub:4.2.0@aar') {
        transitive = true;
    }

    //Google's lib
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.android.gms:play-services-ads:8.3.0'
    compile 'com.android.support:recyclerview-v7:23.1.1'

    //Trusted
    compile 'com.google.guava:guava:18.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:7.0.1'

    //Network and download managers
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.mani:ThinDownloadManager:1.1.0'

    //UI related
    compile 'com.timehop.stickyheadersrecyclerview:library:0.4.1@aar'
    compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
    compile 'com.github.arimorty:floatingsearchview:1.1.2'

}
orhanobut commented 8 years ago

You need to add jcenter() to the repositories part in order to resolve this dependency.

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.orhanobut.tracklytics:tracklytics-plugin:0.10
    }
}

also you don't need to apply fabric plugin. you can select fabric = true in the tracklytics settings and it will be added automatically.

manjunathc23 commented 8 years ago

Thank you so very much. This helps!

maven { url 'https://jcenter.bintray.com' }

This works for me.

Well, Now I have few more questions.

  1. Where do I define the API key for the android:name="io.fabric.ApiKey" ? Do this lib assumes that we define frabic.properties
  2. What about Frabic.Answers() ?

Thanks! Manju

orhanobut commented 8 years ago

Thanks! Totally missed adding this part to README file, I've just updated readme. Basically you need to create tracklytics.properties file on the root level and put fabric key inside. lib will check this file when the fabric is enabled.

I'll try to simplify this process but unfortunately the way fabric works is kind of this way.

When you use trackevent, tracklytics will create a custom answer event and then send it through

  @Override public void trackEvent(String title, Map<String, Object> values) {
    CustomEvent customEvent = new CustomEvent(title);
    //adding event values
    Answers.getInstance().logCustom(customEvent);
  }

Is there any other usage do you need?

manjunathc23 commented 8 years ago

Fantastic! I was wondering why my things are not getting reported in the dashboard till now. Thanks a lot @orhanobut, While you are there can you please mention for apiSecret key as well for frabic?

So basically what I need is I need to initialize the answers kit too. Currently I am doing this way, Correct me if am doing it wrong.

    @Tracklytics(TrackerAction.INIT)
    private Tracker tracklyticsInitialize(@NonNull final Context context) {
        //TODO:: Fabric answers kit is not added by tracklytics
        Fabric.with(context, new Answers());
        return Tracker.init(
                new FabricTrackingAdapter(context)
        );
    }

Thanks! Manju

orhanobut commented 8 years ago

AFAIK, you need apiSecret only for the plugin, correct me If I'm wrong and it's required to be under app folder. Still you can follow the same steps as fabric requires.

About answers, currently the way you do is correct but I'll move Answers initialization to the tracktytics as well, thus you won't need to do anything about it.

Let me know if you everything works OK with fabric, hopefully I'll be able to move all these small details to tracklytics.

manjunathc23 commented 8 years ago

Yeah sure, Thanks a lot for all your support and quick answers!

My current status is I have integrated the SDK it compiles all good and I was able to migrate the code real quick. All looks good so far. Need to see if the am able to report the analytics after doing key update. Will keep you posted in the same thread!

It would be great if you can take the fabric kit's as argument in some way, Like tomorrow if we decide to initialize the MoPub it will be helpful. Let me know your thoughts on this.

You are AWESOME, This lib idea is really helpful for code quality obsessed guy like me. I was looking out for this kind of solution from long time.

manjunathc23 commented 8 years ago

Well, Here is my quick update! I am still unable to report the new events. I have added the key into tracklytics.properties Is there anything else I am missing?

Here is my complete code

public final class MaverickAnalyticsInitializer {

    private static MaverickAnalyticsInitializer sInstance;

    private MaverickAnalyticsInitializer(@NonNull final Context context) {
        tracklyticsInitialize(context);
    }

    public static void init(@NonNull final Context context) {
        sInstance = new MaverickAnalyticsInitializer(context);
    }

    public static MaverickAnalyticsInitializer getInstance() {
        if (sInstance == null) {
            throw new IllegalStateException(
                    "No instance of MaverickAnalyticsInitializer found. " +
                            "Have you called MaverickAnalyticsInitializer.initialize()?");
        }
        return sInstance;
    }

    @Tracklytics(TrackerAction.INIT)
    private Tracker tracklyticsInitialize(@NonNull final Context context) {
        //Fabric answers kit is not added by tracklytics
        Fabric.with(context, new Answers());
        return Tracker.init(
                new FabricTrackingAdapter(context)
        );
    }

Here is the usage

    /**
     * Helper method to track the navigation screen time
     */
    @TrackEvent(MaverickAnalyticsEvents.EVENT_MAIN_SCREEN)
    private void trackNavigationScreenSessionTimeEvent(@TrackValue(MaverickBankIfscAnalyticsAttributes.PAGE_LOAD_TIME) long event) {

    }
    @Override
    protected void onStop() {
        trackNavigationScreenSessionTimeEvent(getTimeStamp());
        super.onStop();
    }

Let me know if am missing anything.

Thanks! Manju

orhanobut commented 8 years ago

I'll check within the day the current code. Meanwhile could you use debugging monitor?

You basically need to add the following code to the activity onCreate, then try to trigger the event again and it should show up on the tracker. If it is shown, then I can check the other reason why it's not being pushed to the fabric server

TracklyticsDebugger.inject(this);
manjunathc23 commented 8 years ago

Yes, I am using it, It logs my events, I can see it happening on the dialog. However my fabric dashboard is not getting update. I am suspecting on the key. Unfortunately fabric SDK is not logging anything as well. Take your time and let me know, No rush, I appreciate your help so far.

Thanks! Manju

manjunathc23 commented 8 years ago

Hey @orhanobut ,

I added Mixed Panel too for my project with same tracking events. However I see no events been reported yet. I feel proguard is doing something? Your thoughts please?

Thanks! Manju

orhanobut commented 8 years ago

@manjunathc23 I haven't tried with proguard, but it's mostly the root of the evil in some cases, possible to try without proguard? I'll try to create a config file for it

manjunathc23 commented 8 years ago

Sure. Will wait for your config file. I am holding my release for this right now.

manjunathc23 commented 8 years ago

I am running into multiple problems

 FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:shrinkProdReleaseMultiDexComponents'.
> java.io.IOException: The output jar [/Users/z087205/Manjunath/Personal/Code/AndroidMaverick/AllIndiaBankInfoV3/app/build/intermediates/multi-dex/prod/release/componentClasses.jar] must be specified after an input jar, or it will be empty.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Unable to build with pro guard for release build.

#TRACKLYTICS
-keep class com.orhanobut.tracklytics.** { *; }
-dontwarn com.orhanobut.tracklytics.**

^ this also not helps. Need help badly here! Thanks! Manju

orhanobut commented 8 years ago

Today within the day I'll hopefully find all requirements for proguard config file. I think that's the biggest reason I hate proguard

manjunathc23 commented 8 years ago

Sure... That would be great!

ergunkocak commented 8 years ago

Following the conversation i learned many things and techiniques :+1: @manjunathc23 your gradle file also helped me a lot in my project :) I know it is not related but just wanted to mention.

manjunathc23 commented 8 years ago

Thanks @ergunkocak

Kiran89kumar commented 8 years ago

Is thr any update on this issue?

sathi-007 commented 8 years ago

finally i got tracklytics working with proguard and minifyEnabled =true in gradle. we have to add

-keep class com.orhanobut.tracklytics.* { ; } -keep interface com.orhanobut.tracklytics.* { ; } -dontwarn com.orhanobut.tracklytics.

along with that we have to keep application class and other activities , fragments wherever we use tracklytics annotations .. for ex:

-keep public class com.cbg.android.lithium.app.LithiumApp { *; }

-keep class com.cbg.android.lithium.app.view.activity.* { ; } -keep interface com.cbg.android.lithium.app.view.activity.* { ; }

-keep class com.cbg.android.lithium.app.view.fragment.* { ; } -keep interface com.cbg.android.lithium.app.view.fragment.* { ; }

hope you find it helpful.. @orhanobut please add this in readme file.

orhanobut commented 7 years ago

I'll add the built-in proguard for 2.0.0 version in order to avoid issues.

orhanobut commented 7 years ago

Closing this issue for now. I opened another issue for proguard to follow up. #40