Closed mehmetalpsumer closed 5 years ago
Hi 👋,
This seems like the Android setup was not correct.
Could you post your complete AndroidManifest
file for me.
I think you might have disabled the automatic registration of WorkManager.
Here is my AndroidManifest
file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.project">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name=".App"
android:label="dostum"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Could you try and add tools:replace="android:name"
in your application
tag?
Also just to make sure post your custom App
class.
@mehmetalpsumer Were you able to solve it?
Hello, Sorry for the delay, I was off yesterday. Unfortunately my problem is not solved. I will share my files.
My manifest file after adding what you have said:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp.myapp">
<application
android:name=".App"
android:label="myaPP"
android:icon="@mipmap/ic_launcher"
tools:replace="android:name">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
My App.kt:
package com.myapp.myapp
import be.tramckrijte.workmanager.WorkmanagerPlugin
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant
class App : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
WorkmanagerPlugin.setPluginRegistrantCallback(this)
}
override fun registerWith(reg: PluginRegistry?) {
GeneratedPluginRegistrant.registerWith(reg)
}
}
Did you try and run the sample app on the same phone/emulator? Does it work there?
Do I just install packages and call flutter run
for the example project? Do I need extra settings?
If I don't need extra configuration, it returned me this:
* Error running Gradle:
ProcessException: Process "C:\Users\xxx\Desktop\flutter_workmanager-master\example\android\gradlew.bat" exited abnormally:
Command: C:\Users\xxx\Desktop\flutter_workmanager-master\example\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Checkout the project.
cd example
> flutter run
Checkout the project.
cd example
>flutter run
I can confirm that I am in the example
directory. Also I have tried to launch with both my phone and emulator.
What is the error? You should be in the example folder not the android folder within the example folder.
C:\Users\xxx\Desktop\flutter_workmanager-master\example\
instead of C:\Users\xxx\Desktop\flutter_workmanager-master\example\android\
I am in the example directory. This is how my terminal looks like:
PS C:\Users\xxx\Desktop\flutter_workmanager-master\example> flutter run
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 0,8s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\xxx\Desktop\flutter_workmanager-master\example\android\gradlew.bat" exited abnormally:
Command: C:\Users\xxx\Desktop\flutter_workmanager-master\example\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
I'm sorry but this has nothing to do with this plugin... Be sure to first investigate this issue first. It seems like you don't even have a working Flutter installation.
Can you run other Flutter projects?
How is your flutter doctor -v
I am nearly at the end of the project that I am developing with flutter, so it is sure not to be an issue related to that. But I can understand it is not related to the plugin as well. I will investigate further and try to update here in case I find the solution, thanks for your time and for the plugin @timrijckaert!
For anyone else having the same issue, I fixed my issue by switching from VS Code to Android Studio. I think it might be related to some Kotlin installations Android Studio made for me. Plugin works now, as intended.
Hello, thanks for the package. I am trying to write data to Google's Firestore every x minutes let's say. I created
App.kt
and set it asandroid:name
. And my main file is as the following:And the error is:
Cheers.