包括Androidx.Work在NativeScript插件中不起作用

时间:2019-09-26 02:09:44

标签: android nativescript androidx android-workmanager nativescript-plugin

我正在创建一个本机脚本插件,并想利用Android(https://developer.android.com/topic/libraries/architecture/workmanager)上的新WorkManager。

这是我要创建Worker的类实例的方式:

 export class GeofenceWorker extends androidx.work.Worker {

            constructor(context, params) {
                super(context,params);
            }

            public doWork(): androidx.work.ListenableWorker.Result {
                console.log("work done");
                return androidx.work.ListenableWorker.Result.success()

            }
        }

但是我仍然出现以下错误:

TS2339: Property 'work' does not exist on type 'typeof androidx'.

按照指南,我在plugin / src / platforms / android / include.gradle中的include.gradle中添加了以下代码

    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
}

dependencies {
    def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : "11.4.0"
    compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
    compile "androidx.work:work-runtime:2.2.0"

}

此外,我还向主要的本机脚本应用程序app.gradle包含了以下代码,该代码已安装了插件:

dependencies {
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation "androidx.work:work-runtime:2.2.0"

}

我还尝试使用主插件中的tns platform clean android清理android平台,但没有成功。

因此,我知道该问题无法访问依赖项。我曾考虑过将.aar库添加到我的项目中,但我可以肯定的是,这仅对于不在存储库中的自定义/非默认api是必需的。 将google()存储库添加到include.gradle也无济于事。

0 个答案:

没有答案