我正在使用 Google App Engine 创建一个由多个Google Modules组成的项目。如何设置我的项目(使用 Maven),以便我可以跨模块共享源代码,例如 Objectify 对象模型定义、共享实用程序代码和单元测试代码?
我希望答案很简单,并且我可以按照以下答案中的建议使用 Maven:
但是,我担心 Google App Engine 模块可能有一些特殊之处,使它们与 Maven 模块不同。然后也许上面的方法行不通。
作为我担心的一个例子,请注意Google 说“虽然 Java EE 支持 WAR 文件,但模块配置仅使用解压的 WAR 目录。” 然而,上面给出的一些解决方案建议将共享代码打包到 JAR 文件中。我意识到 WAR 和 JAR 是不同的,但我担心我会浪费时间尝试做一些不能工作的事情。
关于如何在 Google App Engine 模块之间共享代码的任何建议?
我一直在学习依赖注入(例如Guice),在我看来,其中一个主要的驱动因素,可测试性,已经被Mocking(例如Mockito)很好地覆盖了. 依赖注入和模拟框架之间的区别(Ninject vs RhinoMock或Moq)是依赖注入和Mockito之间共性的一个很好的总结,但它没有提供在能力重叠时使用哪些指南.
我即将设计一个API,我想知道我是否应该:
A]仅使用Mockito
B]使用Guice并设计两个接口实现 - 一个用于实现,一个用于测试
C]一起使用Mockito和Guice - 如果是这样,怎么样?
我猜测正确的答案是C,两者都使用它们,但我想要一些智慧的话:我可以在哪里使用依赖注入或模拟,我应该选择哪个以及为什么?
我只想要一个简单的不可编辑的文本标签,但似乎没有显式的小部件.最接近的似乎是android.widget.TextView.但是文档说"TextView是一个完整的文本编辑器".对于一个简单的标签来说,这似乎有些过分.我不想膨胀我的申请.有更合适的小部件吗?
或者我是以错误的方式接近这个?例如,假设我正在构建一个设置屏幕,是否有一个我应该选择的布局,它为我提供了属性的标签,所以我不必为标签指定小部件?
我正在尝试从 Google Firebase 测试实验室设备下载文件。这些文件是通过运行仪器测试生成的。文件是截图。我需要下载屏幕截图,因为后续运行的测试会将屏幕与这些屏幕截图进行比较。因此,屏幕截图是视觉变化检测的基线。
我尝试寻找一种方法来连接到 Firebase 测试实验室设备的设备文件资源管理器。但似乎没有办法远程访问它。
由于Firebase 测试实验室会在测试后清理设备,因此我认为我可以实现我想要做的唯一方法是向测试添加代码以将文件推送到某个地方。
我想将文件推送到的一个地方是存储测试结果的 Google Cloud 存储桶。从下面的文档来看,这似乎是存储桶的预期用途:
测试实验室完成对您的应用的测试后,您可以在 Firebase 控制台或项目中的 Google Cloud 存储分区中查看测试结果。您还可以在上面显示的 shell 命令中添加 gsutil 命令,以将测试结果数据复制到本地计算机。要了解更多信息,请参阅分析 Firebase 测试实验室结果。( Firebase 文档)
对于这种方法,我的检测测试将如何将文件推送到存储桶?它如何知道使用哪个存储桶?执行文件传输的 API 是什么?
我可以采取的另一种方法是从 Firebase 测试实验室仪器测试 中截取屏幕截图,这会将屏幕截图放入存储桶中。但我看到了两个潜在的问题。
第一个问题是截屏库的截屏可能与从UiAutomation.takeScreenshot()截取的截屏不同。换句话说,基线屏幕截图是使用屏幕截图库拍摄的,但在后续运行中,我将使用 UiAutomation.takeScreenshot() 拍摄屏幕截图并进行比较。由于库不同,它们的屏幕截图可能会有所不同。一个可能的解决方案是使用屏幕截图库拍摄两个屏幕截图。但随后我需要弄清楚如何将屏幕截图读回内存,以便我可以执行比较操作。今天我将它们作为Bitmaps读入。
对于这种方法,我的检测测试将如何将屏幕截图库的屏幕截图加载为Bitmaps?
第二个问题是弄清楚如何将屏幕截图从存储桶下载到我的本地计算机。存储桶的用户界面没有下载按钮。它只有一个上传按钮:
对于这种方法,我如何将文件从存储桶下载到我的本地计算机,以便我可以将它们添加到我的检测测试可以读取的资源目录中?
尝试在将用于 TypeScript 项目的空 git 存储库上将Firebase 添加到您的 JavaScript 项目时,运行时出现以下错误firebase deploy
:
> functions@ build /Users/mosofsky/Documents/Developer/abcplan/functions
> tsc
src/index.ts:1:1 - error TS6133: 'functions' is declared but its value is never read.
1 import * as functions from 'firebase-functions'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! functions@ build: `tsc` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the functions@ build script. npm ERR! This is probably not a problem with …
Run Code Online (Sandbox Code Playgroud) 我试图破译以下错误消息中“范围”的含义:错误:无法加载默认凭据。上下文:firebase登录:ci和firebase auth:export:
[2021-04-27T20:48:23.188Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2021-04-27T20:48:26.208Z] Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at runNextTicks (internal/process/task_queues.js:66:3)
at listOnTimeout (internal/timers.js:518:9)
at processTimers (internal/timers.js:492:7)
at async GoogleAuth.getClient (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)
at async GoogleAuth.getAccessToken (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:524:24)
Error: An unexpected error has occurred.
Run Code Online (Sandbox Code Playgroud)
如果我理解什么是“范围”,我也许能够弄清楚在哪里设置它们。到目前为止,我只找到了一个在 IAM 中为我的用户设置角色和权限的地方。
以下是我能找到的定义:
角色和权限(来源)
角色包含一组权限,允许您对 Google Cloud 资源执行特定操作。要向成员(包括用户、组和服务帐户)提供权限,您可以向成员授予角色。
访问范围是为实例指定权限的传统方法。它们定义来自 gcloud 工具或客户端库的请求中使用的默认 OAuth 范围。
当我尝试使用由 生成并在我的脚本中应用的firebase --debug auth:export
OAuth …
我想从我包含在使用 Google Plugin for Eclipse 的 Google App Engine 项目中的 Objectify 3.1 库中过滤源代码目录。很可能我错误地导入了他们的库,但我想看看是否可以从 Eclipse 中“隐藏”这个源目录,这样它就不会尝试编译它。
我正在尝试使用资源过滤器。项目相对路径似乎最合适,但我无法弄清楚语法。斜杠朝哪个方向走?我在开头加斜杠吗?
java eclipse google-app-engine objectify google-plugin-eclipse
我需要在Java SDK中弃用API以使它们更通用.但我无法弄清楚如何做以下情况:
public class AdoptDog {
public interface OnDogAdoption {
public void onDogAdoption(String dogName);
}
public void adoptDog(final String dogName, OnDogAdoption callbackObj) {
// Perform asynchronous tasks...
// Then call the callback:
callbackObj.onDogAdoption(dogName);
}
}
Run Code Online (Sandbox Code Playgroud)
SDK的用户进行如下调用:
AdoptDog adoptDog = new AdoptDog();
adoptDog.adoptDog("Snowball", new OnDogAdoption {
@Override
public void onDogAdoption(String dogName) {
System.out.println("Welcome " + dogName);
}
};
Run Code Online (Sandbox Code Playgroud)
我想概括从Dog到Pet,并弃用提到Dog的API.为了向后兼容,我在弃用API时不必更改上面采用Snowball的代码片段.
我是如何尝试弃用Dog API的:
// Introduce Pet API
public class AdoptPet {
public interface OnPetAdoption {
public void onPetAdoption(String petName);
}
public void adoptPet(final …
Run Code Online (Sandbox Code Playgroud) 我通过使用新的ConstraintLayout(1.1.2)来平整我的布局,但是当它在一个组中时,我无法再控制ProgressBar的可见性.这是我的布局XML文件的最简单版本,它重现了这个问题:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- This group prevents me from hiding ProgressBar -->
<android.support.constraint.Group
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="imageLoadingSpinner" />
<ProgressBar
android:id="@+id/imageLoadingSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我已经介绍了这个小组以控制一些布局,虽然为了简单起见,我已经把这一切都留下了.该错误的本质是引入该组阻止我将ProgressBar的可见性设置为GONE
.
以下代码不再隐藏ProgressBar:
find(R.id.imageLoadingSpinner).setVisibility(GONE);
Run Code Online (Sandbox Code Playgroud)
需要说明的是,如果我删除该组,如下所示,我可以将ProgressBar的可见性设置为GONE
:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Commenting out this group allows me to hide ProgressBar -->
<!--<android.support.constraint.Group-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--app:constraint_referenced_ids="imageLoadingSpinner" />-->
<ProgressBar
android:id="@+id/imageLoadingSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我找不到有关此问题的任何信息. ProgressBar可见性问题 无关.
在 Android 上,我希望用户能够从列表中选择多行。我读到我可以使用SelectionTracker
aRecyclerView
来启用 list-item selection。
但是所有的代码示例都在 Kotlin 中。SelectionTracker
在Java中有任何例子吗?
android ×4
java ×4
firebase ×3
eclipse ×2
objectify ×2
deprecated ×1
guice ×1
kotlin ×1
maven ×1
mocking ×1
mockito ×1
textview ×1
typescript ×1
unit-testing ×1