小编Car*_*men的帖子

安装MX Player后,SecurityException崩溃会在外部浏览器中打开链接

重现步骤:

  • 禁用或卸载设备上的所有浏览器
  • 安装MX Player
  • 启动MX Player并接受任何弹出窗口
  • 如下所示从应用程序中打开一个链接(假设代码在“活动”中):
val url = "https://mylink.com"
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val resolveInfo = context.packageManager.resolveActivity(intent, 0)
if (resolveInfo != null) {
    startActivity(intent)
} else {
    // error handling because no browser is installed
}
Run Code Online (Sandbox Code Playgroud)

我的应用崩溃了:

java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=https://mylink.com.... cmp=com.mxtech.videoplayer.ad/com.mxtech.videoplayer.ActivityWebBrowser } from ProcessRecord{64f9702 20760:com.myapp/u0a65} (pid=20760, uid=10065) not exported from uid 10139
       at android.os.Parcel.createException + 1966(Parcel.java:1966)
       at android.os.Parcel.readException + 1934(Parcel.java:1934)
       at android.os.Parcel.readException + 1884(Parcel.java:1884)
       at android.app.IActivityManager$Stub$Proxy.startActivity + 3618(IActivityManager.java:3618)
       at android.app.Instrumentation.execStartActivity + …
Run Code Online (Sandbox Code Playgroud)

android android-intent

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

Jacoco 在 Android 项目中报告了单元测试对 Kotlin 类的 0 覆盖率

我正在使用 Android Gradle 插件 3.0.0。

我正在将一个 Android 应用程序从 java 迁移到 kotlin。我的应用程序包含 Java 和 Kotlin 类,测试使用 Java。

我跑./gradlew clean jacocoTestReport

这将运行单元测试 ( src/test) 和仪器测试 ( src/androidTest)。

jacoco in 生成的报告app/build/reports/jacoco/jacocoTestReport/html/index.html没有显示单元测试确实涵盖了 Kotlin 类的覆盖率。

该报告确实从仪器测试中正确显示了覆盖率。

注意:我遇到了这些其他问题,它们不是完全相同的问题:

我的应用程序模块的 build.gradle 的相关部分:

apply plugin: 'jacoco'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
...
android {
    defaultConfig {
        sourceSets {
            main.java.srcDirs …
Run Code Online (Sandbox Code Playgroud)

junit android gradle jacoco kotlin

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

与firebase 11.8.0和google-services插件3.1.2冲突

我与firebase 11.8.0和google-services插件3.1.2存在明显冲突.构建失败,建议我使用版本11.4.2的firebase.

我的gradle构建文件的相关摘录:

build.gradle

buildscript {
    repositories {
        google()
        ...
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.2'
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

应用build.gradle:

apply plugin: 'com.google.gms.google-services'
repositories {
    google()
    ....
}
dependencies {
    implementation "com.google.firebase:firebase-core:11.8.0"
    ....
}
Run Code Online (Sandbox Code Playgroud)

我已经正确生成了firebase app文件:

./app/src/debug/google-services.json
./app/src/release/google-services.json
Run Code Online (Sandbox Code Playgroud)

当我构建时./gradlew clean assembleDebug,构建失败并出现此错误:

> Task :app:processDebugGoogleServices FAILED
Found com.google.firebase:firebase-core:11.8.0, but version 11.4.2 is needed for the google-services plugin.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version …
Run Code Online (Sandbox Code Playgroud)

android gradle firebase google-play-services gradle-plugin

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