0

新的FakeSplitInstallManagerFactory有一个create方法,Context但是当我尝试从我的代码中使用它时,我只得到采用的方法Context和一个File是目录的方法。如果我告诉 AS 显示类的定义,我可以看到这两种create方法。它们都是public,它们都是static,但只能从我的代码中调用一个。我已经尝试过清洁,再次运行 gradle 等。我不明白问题可能是什么?

这是我得到的错误:

在此处输入图像描述

这是我在自动完成时得到的:

在此处输入图像描述

如果我按control+b我得到:

package com.google.android.play.core.splitinstall.testing;

import com.google.android.play.core.splitcompat.SplitCompat;
import com.google.android.play.core.splitinstall.SplitInstallManager;
import android.content.Context;

/** Creates instances of {@link com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager FakeSplitInstallManager}. */

@SuppressWarnings({"unchecked", "deprecation", "all"})
public class FakeSplitInstallManagerFactory {

public FakeSplitInstallManagerFactory() { throw new RuntimeException("Stub!"); }

/**
 * Creates a fake implementation of the {@link com.google.android.play.core.splitinstall.SplitInstallManager SplitInstallManager}.
 *
 * <p>This implementation is self-contained and obtains splits from a specified directory, which
 * can be populated passing the --local-testing flag to bundletool build-apks and using bundletool
 * install-apks to install the app.
 *
 * <p>It is provided for testing, e.g. checking sequences of events when installing dynamic
 * features and additional languages. It is suitable for use in integration tests.
 *
 * <p>This fake supports just one install request at a time.
 *
 * <p>Network errors can be simulated using {@link com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager#setShouldNetworkError(boolean) FakeSplitInstallManager#setShouldNetworkError(boolean)}.
 *
 * <p>{@link com.google.android.play.core.splitcompat.SplitCompat SplitCompat} must be installed appropriately to use this class.
 *
 * <p>This method will always return the same {@link com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager FakeSplitInstallManager} instance.
 */

public static com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager create(android.content.Context context) { throw new RuntimeException("Stub!"); }

/**
 * Alternative version of {@link #create(android.content.Context)} which allows for the splits directory to be set
 * explicitly.
 *
 * <p>The constructor receives the directory on the device where the split apks can be obtained.
 * The file name format is the same as the extracted output of bundletool build-apks. The apks in
 * the directory must be signed by the same certificate as the app. If this directory is missing,
 * install requests will fail with {@link
 * com.google.android.play.core.splitinstall.model.SplitInstallErrorCode#API_NOT_AVAILABLE}.
 *
 * <p>In general, all configuration splits for the module that are present in the folder will be
 * included. Thus, consider pre-filtering them for the device - e.g. using appropriate bundletool
 * build-apks argument. However, since languages can change over time on the device, there will be
 * additional filtering of language splits, whereby only appropriate languages will be included.
 *
 * <p>Prefer using {@link #create(android.content.Context)} and let bundletool populate the default directory,
 * unless there's a good reason to use a different directory or filter the delivered APKs by hand.
 *
 * <p>This method will always return the same {@link com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager FakeSplitInstallManager} instance. It will
 * fail if called twice with different directories.
 */

public static synchronized com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager create(android.content.Context context, java.io.File modulesDirectory) { throw new RuntimeException("Stub!"); }
}

这清楚地显示了两种create方法。

我正在使用 play 核心库1.6.5,这是一个新的清晰项目,没有别的。现在我从模板创建了一个新的干净项目,然后添加implementation "com.google.android.play:core:1.6.5"它,它有完全相同的问题。那么我做错了什么?

谢谢。

4

1 回答 1

1

我知道这很奇怪,但是当您FakeSplitInstallManagerFactory.classcom.google.android.play:coreAAR 进行检查时,无论出于何种原因,他们似乎都忽略了它?这就是为什么它不会让你使用create(context).

public class FakeSplitInstallManagerFactory {
    private static FakeSplitInstallManager a = null;

    public FakeSplitInstallManagerFactory() {
    }

    public static synchronized FakeSplitInstallManager create(Context var0, File var1) {
        if (a == null) {
            try {
                a = new FakeSplitInstallManager(var0, var1);
            } catch (Exception var3) {
                throw new RuntimeException(var3);
            }
        } else if (!a.a().getAbsolutePath().equals(var1.getAbsolutePath())) {
            throw new RuntimeException(String.format("Different module directories used to initialize FakeSplitInstallManager: '%s' and '%s'", a.a().getAbsolutePath(), var1.getAbsolutePath()));
        }

        return a;
    }
}

也许他们稍后会添加它,因为文档,本地测试模块安装:模拟网络错误提到了缺少的方法(或者他们可能会弃用它而支持create(context, file)但只是没有更新文档),我们会看到...

但是这里有一个最近的媒体/一种测试离线动态交付的简单方法,它谈到了如何使用create(context, file)

于 2020-02-25T18:51:13.217 回答