android jacoco coverage empty with gradle

前端 未结 8 2132
旧巷少年郎
旧巷少年郎 2021-01-12 23:39

I\'m trying to make jacoco create a code coverage report for my android test project. I have the following in build.gradle:

apply plugin: \'com.android.appli         


        
相关标签:
8条回答
  • 2021-01-13 00:27

    Sometimes due to some security restrictions on the underlying hardware you are unable to get coverage reports. In my case I was using android:sharedUserId="android.uid.system" and due to this it was not picking up any coverage and was giving me an empty file.

    So I agree naran that you should try running it on different devices and make sure your app is not using android:sharedUserId="android.uid.system".

    0 讨论(0)
  • 2021-01-13 00:28

    Jacoco should be inside of the android closure and the jacoco plugin declaration is not necessary:

    apply plugin: 'com.android.application'
    ...
    android {
        buildTypes {
            release {
            }
            debug {
                testCoverageEnabled true
            }
        }
        jacoco {
            toolVersion = "0.7.1.201405082137"
        }
    }
    
    0 讨论(0)
提交回复
热议问题