正确调整 android sdk 配置但不正确 运行

Adjust android sdk config correct but not run correctly

我遵循了 this document,并创建了这段代码:

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) {
    }
}

然后构建application.I可以看到下面的日志:

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

问题是我在服务器端看不到任何记录。请帮忙。

这是我的 build.gradle:

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

[求解]

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);
}

将环境更改为生产环境:

删除

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

并且只需使用

environment = AdjustConfig.ENVIRONMENT_PRODUCTION;