小编Lin*_*ino的帖子

未知命令:使用 adb shell 时 verify-app-links pm verify-app-links

我正在使用以下应用程序链接:https ://developer.android.com/training/app-links/verify-site-associations

使用cmd时:adb shell pm verify-app-links

show: Unknown command: verify-app-links
Run Code Online (Sandbox Code Playgroud)

我的adb版本是:

$ adb --version
Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
Run Code Online (Sandbox Code Playgroud)

几乎是最新的,为什么未知命令:verify-app-links?

android adb android-app-links

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

无法使用 jetpack Compose 获取测试结果(始终显示为已取消)

我正在尝试使用 jetpack 进行简单的测试,如下所示

@MediumTest
@RunWith(JUnit4::class)
class LoginScreenTest {

    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun test1() {
        composeTestRule.setContent { 
            Text(text = "HEY")
        }
        composeTestRule.onNodeWithText("HEY").assertIsDisplayed()
    }
}
Run Code Online (Sandbox Code Playgroud)

但是虽然成功了,但是在android studio中总是显示为canceled 在此输入图像描述

只有logcat可以显示是否出现故障

I/TestRunner: run finished: 1 tests, 0 failed, 0 ignored
Run Code Online (Sandbox Code Playgroud)

那么知道如何解决这个问题吗?任何帮助将不胜感激

Compose version : 1.0.0-alpha11
Run Code Online (Sandbox Code Playgroud)

testing android kotlin android-jetpack android-jetpack-compose

5
推荐指数
1
解决办法
493
查看次数

gradle 错误链接到 build.gradle 文件上的命名空间

我一直有这个错误,但我已经做了他们要求我做的事情。

这是错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':audio_service'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

     android {
         namespace 'com.example.namespace'
     }

     If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for …
Run Code Online (Sandbox Code Playgroud)

android gradle dart flutter

5
推荐指数
1
解决办法
5106
查看次数

管道多个 jenkins 作业

我对詹金斯很陌生。

Jenkins 中已经配置了多个作业,到目前为止,我们正在一个接一个地手动运行所有作业。我想通过管道插件使其成为一项单一的工作,从而减少手动工作。

我已经浏览了链接,它指出我们应该在我们的存储库中有 JenkinsFile 它基本上包含执行不同任务的命令。

但是如果我在 JenkinsFile 中配置它,如何给出现有的作业名称?

这是做管道的唯一方法还是有其他方法可以实现这一目标?

例如:我有三份工作

  1. 构建开发代码
  2. 测试开发代码
  3. 部署阶段

我想管道所有三个工作,

  deploy-stage-ci 
Run Code Online (Sandbox Code Playgroud)

以便它包含上述所有 3 个作业。

continuous-integration continuous-deployment jenkins-pipeline

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

改造可为空参数映射

我有改造接口

interface ApiInterface {

    @GET
    Observable<okhttp3.ResponseBody> get(@Url String url,
                                         @HeaderMap Map<String, Object> headerMap,
                                         @QueryMap HashMap<String, String> queryMap );
}
Run Code Online (Sandbox Code Playgroud)

我这样调用,它完美地工作

HashMap<String, String> map = new HashMap<String, String>();
map.put("id","xyz");
apiInterface.get(url,  getHeader(),map)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)

但是当我通过时null,它不起作用

return apiInterface.get(url,  getHeader(),null)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)

如何通过 null 来改造接口?

java android retrofit2

3
推荐指数
1
解决办法
769
查看次数

为什么 trySend 会发出假数据?

我需要在 MVVM 中获取用户身份验证状态。在存储库中我这样做:

override fun getAuthResponse() = callbackFlow  {
    val listener = AuthStateListener {
        Log.d(TAG, "currentUser: " + (currentUser == null)) //Line2
        trySend(it.currentUser == null)
    }
    auth.addAuthStateListener(listener)
    awaitClose {
        auth.removeAuthStateListener(listener)
    }
}
Run Code Online (Sandbox Code Playgroud)

“Line2”将始终打印,true因为用户未经过身份验证。然后在 ViewModel 中我有:

fun getAuthResponse() = repo.getAuthResponse()
Run Code Online (Sandbox Code Playgroud)

以及内部活动:

setContent {
    //...
    val response = viewModel.getAuthResponse().collectAsState(initial = false).value
    Log.d(TAG, "response: $response") //Line1
}
Run Code Online (Sandbox Code Playgroud)

由于 setContent 是一个可组合函数,因此当我打开应用程序时,它会触发两次。这意味着“Line1”处的日志语句被触发两次。当它第一次点火时,我得到:

response: false
currentUser: true
Run Code Online (Sandbox Code Playgroud)

因此,即使我在前一行调用了 getAuthResponse(),响应也会在之前打印。问题是,由于某种原因,即使当前用户为空,我也会在活动中打印出该用户不为空。当它第二次触发时,我得到了正确的数据:

response: true
currentUser: true
Run Code Online (Sandbox Code Playgroud)

为什么我得到一个非空的用户对象?trySend 会发出假数据吗?

kotlin firebase kotlin-coroutines android-jetpack-compose kotlin-flow

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

如何从更快的原始流中延迟发出最新值?

我有2个流量。第一个流每 50 毫秒更新一次。我有第二个流,它等于第一个流,但我希望它每 300 毫秒从原始流生成最新值。我找到了debounce流程扩展,但它不起作用(文档中的注释):

Note that the resulting flow does not emit anything as long as the original flow emits items faster than every timeoutMillis milliseconds.

因此,当我尝试每 300 毫秒发出一次带有去抖动的值时,它根本不会发出,因为原始流比我需要的要快。那么我怎样才能做这样的事情:

  1. 延迟300ms
  2. 检查原始流量的最新值
  3. 发出这个值
  4. 重复

我现在的流程:

// fast flow (50ms)
val orientationFlow = merge(_orientationFlow, locationFlow)

val cameraBearingFlow = orientationFlow.debounce(300ms)
Run Code Online (Sandbox Code Playgroud)

PS 这种方法不适合,因为我们延迟了值,所以 300 毫秒后它就不再新鲜了。我需要在 300 毫秒后获取最新值:

val cameraBearingFlow = azimuthFlow.onEach { 
        delay(ORIENTATION_UPDATE_DELAY)
        it
    }
Run Code Online (Sandbox Code Playgroud)

kotlin kotlin-coroutines kotlin-flow

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

如何获取从 android 10 上的图库中选择的视频的路径

我尝试了很多片段。这就是我现在正在使用的。我知道 MediaStore.Video.Media.DATA 已弃用。不知何故此方法也适用于 android 10,但有时会抛出

android.database.CursorIndexOutOfBoundsException: 请求索引 0,大小为 0

public static String getvideoPath(Context context, Uri uri) {
    try {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        cursor.moveToFirst();
        String document_id = cursor.getString(0);
        LogMessage.v("Document Id:: "+document_id);
        if(document_id!=null){
        document_id = document_id.substring(document_id.lastIndexOf(":") + 1);
        cursor.close();
        cursor = context.getContentResolver().query(
                MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                null, MediaStore.Video.Media._ID + " = ? ", new String[]{document_id}, null);
        cursor.moveToFirst();
        String path = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
        cursor.close();
        return path;
        }else
            return getPath(context,uri);
    } catch (Exception e) {
        e.printStackTrace();
        return getPath(context,uri);
    }
}

private static String …
Run Code Online (Sandbox Code Playgroud)

java android path android-contentresolver

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

在反编译的 apk 上恢复启用缩小和 proguard 效果

我以前开发过一个应用程序,现在我找不到我的应用程序源代码。
我想对我的应用程序进行一些更改。

现在我只有我的密钥库(jks 文件),我之前用它来签署我的应用程序。
我使用在线 Apk Decompiler反编译我的应用程序,但它没有给出我想要的结果。我需要它来编辑我的代码并将其提供给客户,但它为我提供了如下所示的代码预览,其中包含难以理解的类和方法名称。

我反编译的APK文件夹目录

文件夹目录

我的代码预览

代码预览

我知道这个问题是为了在 gradle 中将发布模式的 minify enabled设置为 true 。

有什么方法可以将反编译的代码恢复为可理解的代码,或者使用密钥库将其恢复或使用可理解的源代码反编译应用程序 apk 文件?

我真的需要反编译这个 apk 并对其进行一些更改。特别是应用程序源文件。

任何帮助将不胜感激 :)

java android apk

0
推荐指数
1
解决办法
220
查看次数

List Util fastAny() 函数未解决

fastAny()我正在使用以下示例代码尝试 Kotlin 的 List Util函数:

fun main() {

    val list = mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    val predicate = list.fastAny { it > 3 }

}
Run Code Online (Sandbox Code Playgroud)

函数正在Android project解析,但尚未解析IntelliJ project. 在此输入图像描述

我可能会错过什么?

android list kotlin

0
推荐指数
1
解决办法
53
查看次数