Adjust android sdk config correct but not run correctly

2.9k views Asked by At

I followed this document, and created this code:

public class MainApplication extends Application {

public static MainApplication instance;

@Override
public void onCreate() {
    super.onCreate();

    //Config for Adjust :::::
    String appToken = null;
    appToken = getString(R.string.adjust_key); // something like : `dddkt4ey8xz1`

    String environment;
    if (BuildConfig.DEBUG)
        environment = AdjustConfig.ENVIRONMENT_SANDBOX;
    else
        environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
    AdjustConfig config = new AdjustConfig(this, appToken, environment);
    // change the log level
    config.setLogLevel(LogLevel.VERBOSE);   // enable all logging
    config.setLogLevel(LogLevel.DEBUG);     // enable more logging
    config.setLogLevel(LogLevel.INFO);      // the default
    //        config.setLogLevel(LogLevel.WARN);      // disable info logging
    //        config.setLogLevel(LogLevel.ERROR);     // disable warnings as well
    //        config.setLogLevel(LogLevel.ASSERT);    // disable errors as well

    // enable event buffering
    //        config.setEventBufferingEnabled(true);

    // set default tracker
    config.setDefaultTracker(getString(R.string.adjust_key));

    // set process name
    //        config.setProcessName("com.adjust.example");

    // set attribution delegate
    config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
        @Override
        public void onAttributionChanged(AdjustAttribution attribution) {
            Timber.tag("Adjust").d("attribution: " + attribution.toString());
        }
    });
    Adjust.onCreate(config);
    registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());

    // put the SDK in offline mode
    //Adjust.setOfflineMode(true);

    // Enable the SDK
    Adjust.setEnabled(true);
}
private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks {
    @Override
    public void onActivityResumed(Activity activity) {
        Adjust.onResume();
    }

    @Override
    public void onActivityPaused(Activity activity) {
        Adjust.onPause();
    }

    @Override
    public void onActivityStopped(Activity activity) {
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    }

    @Override
    public void onActivityStarted(Activity activity) {
    }
}

Then built the application.I can see below logs :

W/Adjust: SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to `production` before publishing!
I/Adjust: Google Play Services Advertising ID read correctly at start time
I/Adjust: Default tracker: 'dddkt4ey8xz1'
I/Adjust: Session tracked

The problem is I can not see any records at the Server side. Please help.

Here is my build.gradle:

compile 'com.adjust.sdk:adjust-android:4.11.4'
compile 'com.google.android.gms:play-services-analytics:10.2.1'

[SOLVE]

private void applyAdjustSDK() {
    //Config for Adjust :::::
    String appToken = null;
    appToken = getString(R.string.adjust_token); // something like : `dddkt4ey8xz1`

    String environment =  AdjustConfig.ENVIRONMENT_SANDBOX;

    if (!BuildConfig.DEBUG)
        environment = AdjustConfig.ENVIRONMENT_PRODUCTION;

    AdjustConfig config = new AdjustConfig(this, appToken, environment);
    // change the log level
    config.setLogLevel(LogLevel.VERBOSE);   // enable all logging
    config.setLogLevel(LogLevel.DEBUG);     // enable more logging
    config.setLogLevel(LogLevel.INFO);      // the default
    //        config.setLogLevel(LogLevel.WARN);      // disable info logging
    //        config.setLogLevel(LogLevel.ERROR);     // disable warnings as well
    //        config.setLogLevel(LogLevel.ASSERT);    // disable errors as well

    // enable event buffering
    //        config.setEventBufferingEnabled(true);

    // set default tracker
    config.setDefaultTracker(getString(R.string.adjust_token));

    // set process name
    //        config.setProcessName("com.adjust.example");

    // set attribution delegate
    config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
        @Override
        public void onAttributionChanged(AdjustAttribution attribution) {
            Timber.tag("Adjust").d("attribution: " + attribution.toString());
        }
    });
    Adjust.onCreate(config);
    registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());

    // put the SDK in offline mode
    //Adjust.setOfflineMode(true);

    // Enable the SDK
    Adjust.setEnabled(true);
}
1

There are 1 answers

0
Divyesh Patel On BEST ANSWER

change Environment to Production:

remove

if (BuildConfig.DEBUG) 
      environment = AdjustConfig.ENVIRONMENT_SANDBOX; 
else
      environment = AdjustConfig.ENVIRONMENT_PRODUCTION; 

and just use

environment = AdjustConfig.ENVIRONMENT_PRODUCTION;