小编Gen*_*ror的帖子

Android Instrumentation测试安装APK失败

我想将仪器测试作为 CI 管道的一部分运行,但是当我运行测试时,它们会失败,因为无法安装 APK(据我所知):

> Task :app:connectedDebugAndroidTest FAILED
Mar 18, 2022 3:00:59 PM com.google.testing.platform.RunnerImpl run
SEVERE: Test execution failed with fatal error!
com.google.testing.platform.api.plugin.PluginException: Exception thrown during onBeforeAll invocation of plugin com.google.testing.platform.plugin.android.AndroidDevicePlugin.
        at com.google.testing.platform.plugin.PluginLifecycleKt.invokeOrThrow(PluginLifecycle.kt:216)
        at com.google.testing.platform.plugin.PluginLifecycleKt.invokeOrThrow$default(PluginLifecycle.kt:205)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1.invoke(PluginLifecycle.kt:92)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1.invoke(PluginLifecycle.kt:88)
        at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:105)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent$default(Telemetry.kt:98)
        at com.google.testing.platform.plugin.PluginLifecycle.onBeforeAll(PluginLifecycle.kt:88)
        at com.google.testing.platform.executor.SingleDeviceExecutor$execute$4.invoke(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.executor.SingleDeviceExecutor$execute$4.invoke(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.executor.SingleDeviceExecutor.runUnlessCancelled(SingleDeviceExecutor.kt:105)
        at com.google.testing.platform.executor.SingleDeviceExecutor.execute(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.RunnerImpl.run(RunnerImpl.kt:108)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:80)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:79)
        at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:66)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy.run(NonInteractiveServerStrategy.kt:79)
        at com.google.testing.platform.main.MainKt$main$4.invokeSuspend(Main.kt:67)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at …
Run Code Online (Sandbox Code Playgroud)

android android-virtual-device android-instrumentation

17
推荐指数
2
解决办法
1万
查看次数

Dockerfile 中的 setfacl 不起作用

我想在使用 setfacl 构建 docker 映像时为某些文件夹设置默认 acl 但它没有效果。默认 acl 不变。我的目标是在 /opt 中创建的每个文件都必须对任何用户具有 rwX 权限,因为该映像稍后将使用任意 uid 运行,并且需要对 /opt 的完全访问权限。

这是一个快速示例 Dockerfile

FROM ubuntu:bionic
SHELL ["/bin/bash", "-c"]
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends acl > /dev/null
RUN chmod -R a+rwXs /opt
RUN setfacl -d -m o::rwx /opt
RUN getfacl /opt
Run Code Online (Sandbox Code Playgroud)

输出是

# file: opt
# owner: root
# group: root
# flags: ss-
user::rwx
group::rwx
other::rwx
Run Code Online (Sandbox Code Playgroud)

这是错误的,缺少默认的 acl。但是如果我手动运行容器中的命令,它就可以工作

docker run -ti --rm ubuntu:bionic bash
root@636bf8fdba41:/# apt-get update > /dev/null …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu acl docker dockerfile

6
推荐指数
1
解决办法
1174
查看次数

如何在 Android (kotlin) 中访问 assets-pack 数据

我使用资产包库在我的 Android kotlin 应用程序中打包了一些资产:https : //developer.android.com/guide/app-bundle/asset-delivery/build-native-java

不是我应该能够使用AssetManagervia访问资产context.assets。但是,我不知道正确的路径是什么。

我的资产包被调用models并在文件的根文件夹中正确创建.aab,所以我猜它也被正确安装。在此处输入图片说明

现在根据文档(https://developer.android.com/guide/playcore/asset-delivery/integrate-java)我可以访问这样的资产:

import android.content.res.AssetManager;
...
Context context = createPackageContext("com.example.app", 0);
AssetManager assetManager = context.getAssets();
InputStream is = assetManager.open("asset-name");
Run Code Online (Sandbox Code Playgroud)

我将包名更改为我的包名。但是资产名称是什么?!?这不是我的models资产文件夹中文件的名称。我尝试 assetManager.list(p)p任何我能想到的方法,但我找不到我的资产的存储位置。

对于p=''结果assetManager.list(p)

 hw_pc_white_apps.xml
    hw_pc_white_apps_pad.xml
    images
    permission_grant_policy.xml
    permission_grant_policy_oversea.xml
    pfw
    sfpconfig.json
    ukeyapp.xml
    water.frag
    water.vert
    webkit
    wifi_policy.xml
    wifipro_regexlist.xml
Run Code Online (Sandbox Code Playgroud)

这对我来说也毫无意义。如何从资产包中访问资产?

android android-assets kotlin

4
推荐指数
1
解决办法
1763
查看次数

在 FastAPI 中等待 request.json() 永远挂起

我将此处给出的异常处理(https://github.com/tiangolo/fastapi/discussions/6678)添加到我的代码中,但我想打印完整的请求正文以查看完整的内容。但是,当我等待时,request.json()它永远不会终止。request.json()返回一个协程,因此我需要等待协程完成才能打印结果。如果向端点发送了无效请求,如何打印请求内容?

来自 github 的代码示例,我在错误处理程序和一个简单的端点中进行了 2 处更改。

import logging
from fastapi import FastAPI, Request, status
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from pydantic import BaseModel

app = FastAPI()


@app.exception_handler(RequestValidationError)
async def validation_exception_handler(
    request: Request, exc: RequestValidationError
) -> JSONResponse:
    exc_str = f"{exc}".replace("\n", " ").replace("   ", " ")
    logging.error(f"{request}: {exc_str}")
    body = await request.json()  # This line was added by me and never completes
    logging.error(body)  # This line was added by me
    content = …
Run Code Online (Sandbox Code Playgroud)

python freeze exceptionhandler starlette fastapi

4
推荐指数
1
解决办法
586
查看次数