admin管理员组文章数量:1125111
I need to create remote worker on a separate thread. I'm following this answer for things I need to do and I'm stuck at declaring dependencies.
I need to add implementation "androidx.work:work-multiprocess:$work_version"
somewhere.
How do I do that in .NET Android project?
I'm using Xamarin.AndroidX.Work.Runtime
2.10.0.1 package to work with workers.
here's the application
section in my manifest
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:supportsRtl="true">
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge" >
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
<service
android:name="androidx.work.multiprocess.RemoteWorkManagerService"
tools:replace="android:process"
android:process=":ffmpegWorker"/>
<service
android:name="androidx.work.impl.background.systemjob.SystemJobService"
tools:replace="android:process"
android:process=":ffmpegWorker"/>
</application>
In my MainActivity
RemoteWorkManager.GetInstance(BaseContext)
throws the following error:
Java.Lang.IllegalStateException: Invalid multiprocess configuration. Define an 'implementation' dependency on :work:work-multiprocess library
var inputData = new Data.Builder()
.PutString(nameof(_fifoFilename), _fifoFilename)
.Build();
var ffmpegWorker = OneTimeWorkRequest.Builder.From<FfmpegWorker>()
.SetInputData(inputData)
.Build();
try
{
if (!WorkManager.IsInitialized)
{
var configuration = new Configuration.Builder()
.SetDefaultProcessName(":ffmpegWorker")
.Build();
WorkManager.Initialize(BaseContext, configuration);
}
var manager = RemoteWorkManager.GetInstance(BaseContext);
manager.Enqueue(ffmpegWorker);
}
catch (Exception e)
{
}
I need to create remote worker on a separate thread. I'm following this answer for things I need to do and I'm stuck at declaring dependencies.
I need to add implementation "androidx.work:work-multiprocess:$work_version"
somewhere.
How do I do that in .NET Android project?
I'm using Xamarin.AndroidX.Work.Runtime
2.10.0.1 package to work with workers.
here's the application
section in my manifest
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:supportsRtl="true">
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge" >
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
<service
android:name="androidx.work.multiprocess.RemoteWorkManagerService"
tools:replace="android:process"
android:process=":ffmpegWorker"/>
<service
android:name="androidx.work.impl.background.systemjob.SystemJobService"
tools:replace="android:process"
android:process=":ffmpegWorker"/>
</application>
In my MainActivity
RemoteWorkManager.GetInstance(BaseContext)
throws the following error:
Java.Lang.IllegalStateException: Invalid multiprocess configuration. Define an 'implementation' dependency on :work:work-multiprocess library
var inputData = new Data.Builder()
.PutString(nameof(_fifoFilename), _fifoFilename)
.Build();
var ffmpegWorker = OneTimeWorkRequest.Builder.From<FfmpegWorker>()
.SetInputData(inputData)
.Build();
try
{
if (!WorkManager.IsInitialized)
{
var configuration = new Configuration.Builder()
.SetDefaultProcessName(":ffmpegWorker")
.Build();
WorkManager.Initialize(BaseContext, configuration);
}
var manager = RemoteWorkManager.GetInstance(BaseContext);
manager.Enqueue(ffmpegWorker);
}
catch (Exception e)
{
}
Share
Improve this question
edited 2 days ago
Pavlo Holotiuk
asked 2 days ago
Pavlo HolotiukPavlo Holotiuk
2672 silver badges10 bronze badges
1 Answer
Reset to default 0The proper solution would be to ask owners of Xamarin.AndroidX.Work.Runtime
to include this package in their binding library which I have done. They will need to add bindings for classes used in that java package. (or I will have to create my own binding library)
I found a workaround for adding java dependencies but it has not fixed the problem of its classes not being supported in aforementioned nuget but maybe it will help somebody:
Download java library (aar and pom).
Open pom file and delete everything that is already referenced through referenced nuget packages (I had
Xamarin.AndroidX.Work.Runtime
which already had all references so I deleted all). It's important as nested references cannot be found by analyzer and duplicating references will lead to ambigous definition error later.Put .aar and .pom files to project directory.
Add
<AndroidLibrary Include="yourfilename.aar" Manifest="yourfilename.pom" />
to your csproj file.Add suggested in the errors nuget packages that for some reason are still required despite removing them from dependencies. (or repeat the process for java libraries if there are no nugets available)
Next, I received a lot of errors about some class not implementing abstract members. It's probably related to binding library I'm using being outdated. Double click the error and replace virtual with override in required methods. (Not sure where the changes are being saved. They aren't reflected in git and reset every time you change something in csproj)
After all this, the project is compiled and runs. I no longer receive an exception requesting to add a dependency.
本文标签: cHow to declare java implementation dependency in net androidStack Overflow
版权声明:本文标题:c# - How to declare java implementation dependency in .net android? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736655724a1946248.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论