无法使用Firebase测试实验室创建TelephonyManager

时间:2020-04-07 17:33:18

标签: android telephonymanager firebase-test-lab

我正在尝试在Firebase测试实验室上运行一些测试。 我有一个很小的应用程序,只有一个简单的活动,并且有一些逻辑可以使用TelephonyManager运行一些检查。

我可以在本地成功运行该应用程序和检测测试。

当我运行测试调用时:

gcloud beta firebase test android run --network-profile=LTE --app /Users/myuser/projects/Test5G/app/build/outputs/apk/debug/app-debug.apk --type instrumentation --test /Users/myuser/projects/Test5G/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk

运行测试(在Pixel 2,API级别26上),并且由于它们仅包含一个非常简单的测试:

@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        assertEquals("com.example.test5g", appContext.packageName)
    }
}

他们成功了,但检查了Firebase上的logcat:

E 10:18:31.087 VvmPkgInstalledRcvr无法从以下位置创建TelephonyManager ComponentInfo {com.android.phone/com.android.services.telephony.TelephonyConnectionService}, [****],UserHandle {0}

E 10:18:31.587 GooglePlayServicesUtil Google 找不到播放服务资源。检查你的项目 配置以确保包括资源。

build.gradle是:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.test5g"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.3.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

0 个答案:

没有答案