测试Google Play安装推荐人库

Bar*_*eld 28 java android google-analytics google-play install-referrer

我希望从收听Play商店的INSTALL_REFERRER意图迁移到使用新的Google Play安装引荐库.

我很难找到一种方法来测试这个新的库,而无需先将我的应用程序添加到Play商店.通过BroadcastReceiver监听INSTALL_REFERRER意图时,我可以通过活动管理器手动发送广播来模拟行为进行测试.也就是说,我可以按照Google的这些步骤进行测试.

是否还有一种方法可以测试这个新库而无需先将我的应用程序放在Play商店中?

小智 29

有一个古老的黑客来测试这个。

脚步:

  1. 使用广告系列链接在设备上启动 Google Play,例如https://play.google.com/store/apps/details?id=com.test.test_project&referrer=utm_source%3Dtest_source%26utm_medium%3Dtest_medium%26utm_term%3Dtest-term %26utm_content%3Dtest_content%26utm_campaign%3Dtest_name (你可以使用谷歌播放生成器:https : //developers.google.com/analytics/devguides/collection/android/v3/campaigns#google-play-url-builder

  2. 不要点击安装按钮

  3. 使用 adb 安装您的测试版本。 adb install -r app-debug.apk

Google Play 现在将返回您的测试广告系列。

  • 通过 adb 安装后,您应该会看到“安装”按钮更改为“打开”按钮。您必须通过按钮(不使用 adb am)打开应用程序才能获取 UTM 有效负载。如果您没有看到按钮文本发生变化,那是因为已安装应用程序的应用程序 ID 与 Play 商店中的应用程序 ID 不同。如果您发布了应用程序的“产品”风格,但正在使用“调试”风格,则可能会出现这种情况,暂时更改调试应用程序的应用程序 ID,以上内容应该可以工作! (4认同)

小智 7

这是我的测试总结\xef\xbc\x9a

\n
    \n
  1. 旧的广播方式可以测试,但已弃用,暂时不支持
  2. \n
  3. 你可以测试安装使用adb\xef\xbc\x8can设置的referrer lib,你会得到utm_source=google-play&utm_medium=organic,就像直接从Google Play下载一样。\n但我们无法获得更多信息,它是只能测试你的库设置是否正确
  4. \n
  5. /sf/answers/4223972441/作者:@Quickern。说实话,它可以按照以下提示进行操作\n
      \n
    • 确保应用程序 ID 相同。\n\n
    • \n
    • 直接通过 Google Play 应用打开测试网址(无需下载)\n\n
    • \n
    • 使用 adb 安装您的测试应用程序
    • \n
    • 打开您的应用程序,您将收到您在网址中设置的内容
    • \n
    \n
  6. \n
  7. 使用 Google Play 提供的 Beta 测试:/sf/answers/3482553091/。\n毫无疑问,它可以工作
  8. \n
  9. 使用模拟器\xef\xbc\x9a/sf/answers/4182094941/ @Marilia。我没有测试这个,因为带有Google Play商店的模拟器就像一个真实的设备。答案说条件是将应用程序上传到Google Play商店\xef\xbc\x8cso我认为这就像第4条一样
  10. \n
\n


yoz*_*hik -5

也许有些人会需要这个。我创建了测试应用程序,这里是仅一项所需活动的源代码。这是关于如何添加 Play Install Referrer 库:https://developer.android.com/google/play/installreferrer/library

这里还有很好的描述:https://android-developers.googleblog.com/2017/11/google-play-referrer-api-track-and.html

package com.cat.red.rsamazingapp;

import android.os.RemoteException;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.android.installreferrer.api.InstallReferrerClient;
import com.android.installreferrer.api.InstallReferrerStateListener;
import com.android.installreferrer.api.ReferrerDetails;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

public class MainActivity extends AppCompatActivity implements InstallReferrerStateListener {

    private static final String TAG = "RSD";
    InstallReferrerClient mReferrerClient;
    TextView txtBody;
    StringBuilder stringBuilder;

    private int attemps = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        txtBody = (TextView) this.findViewById(R.id.txt_body);
        stringBuilder = new StringBuilder();
        stringBuilder.append("\nonCreate");

        mReferrerClient = InstallReferrerClient.newBuilder(this).build();
        stringBuilder.append("\n1. onCreate.isReady == " + mReferrerClient.isReady());
        mReferrerClient.startConnection(this);
        stringBuilder.append("\nstartConnection");
        stringBuilder.append("\n2. onCreate.isReady == " + mReferrerClient.isReady());
    }

    @Override
    public void onInstallReferrerSetupFinished(int responseCode) {
        stringBuilder.append("\nonInstallReferrerSetupFinished");

        switch (responseCode) {
            case InstallReferrerClient.InstallReferrerResponse.OK:
                // Connection established
                stringBuilder.append("\nonInstallReferrerSetupFinished. InstallReferrer conneceted. Success");
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());

                try {
                    ReferrerDetails installReferrerDetails = mReferrerClient.getInstallReferrer();
                    if (installReferrerDetails == null) {
                        stringBuilder.append("\ninstallReferrerDetails == NULL");
                    }

                    if (installReferrerDetails != null) {
                        stringBuilder.append("\ngetInstallReferrer = " + installReferrerDetails.getInstallReferrer());
                        stringBuilder.append("\ngetInstallBeginTimestampSeconds = " + installReferrerDetails.getInstallBeginTimestampSeconds());
                        stringBuilder.append("\ngetReferrerClickTimestampSeconds = " + installReferrerDetails.getReferrerClickTimestampSeconds());
                    }
                } catch (RemoteException e) {
                    stringBuilder.append("\nonInstallReferrerSetupFinished. exception: " + e.getMessage());
                    txtBody.setText(stringBuilder.toString());
                    e.printStackTrace();
                }
                break;
            case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
                stringBuilder.append("\nonInstallReferrerSetupFinished. Install Referrer API not supported by the installed Play Store app.");
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
                break;
            case InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
                // Connection could not be established
                stringBuilder.append("\nonInstallReferrerSetupFinished. Could not initiate connection to the Install Referrer service.");
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
                break;
            case InstallReferrerClient.InstallReferrerResponse.SERVICE_DISCONNECTED:
                stringBuilder.append("\nonInstallReferrerSetupFinished. Play Store service is not connected now - potentially transient state");
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
                break;
            case InstallReferrerClient.InstallReferrerResponse.DEVELOPER_ERROR:
                stringBuilder.append("\nonInstallReferrerSetupFinished. General errors caused by incorrect usage.");
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
                break;
            default:
                stringBuilder.append("\nonInstallReferrerSetupFinished. responseCode not found. code = " + responseCode);
                stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
        }

        stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
        mReferrerClient.endConnection();
        stringBuilder.append("\nendConnection");
        stringBuilder.append("\nisReady == " + mReferrerClient.isReady());

        txtBody.setText(stringBuilder.toString());
    }

    @Override
    public void onInstallReferrerServiceDisconnected() {
        // Try to restart the connection on the next request to
        // Google Play by calling the startConnection() method.
        stringBuilder.append("\nonInstallReferrerServiceDisconnected. attemptCount = " + attemps);
        stringBuilder.append("\nisReady == " + mReferrerClient.isReady());

        if (attemps < 3) {
            attemps++;
            stringBuilder.append("\nonInstallReferrerServiceDisconnected. RE-startConnection");
            mReferrerClient.startConnection(this);
        } else {
            stringBuilder.append("\nonInstallReferrerServiceDisconnected. endConnection");
            stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
            mReferrerClient.endConnection();
            stringBuilder.append("\nendConnection");
            stringBuilder.append("\nisReady == " + mReferrerClient.isReady());
        }

        txtBody.setText(stringBuilder.toString());
    }

    @Override
    protected void onResume() {
        super.onResume();
        stringBuilder.append("\nonResume. isReady == "+ mReferrerClient.isReady());
    }

    public static String format(GregorianCalendar calendar){
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        fmt.setCalendar(calendar);
        String dateFormatted = fmt.format(calendar.getTime());
        return dateFormatted;
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 上面只是一个“示例”代码,但没有展示如何在上传到 Play 商店之前测试应用程序。 (4认同)