0

我遵循了这个文档,并创建了这个代码:

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

然后构建应用程序。我可以看到以下日志:

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

1 回答 1

2

将环境更改为生产:

消除

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

并使用

environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
于 2017-05-19T09:07:05.800 回答