-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Attempt to read from field 'java.lang.String io.flutter.embedding.engine.loader.FlutterApplicationInfo.flutterAssetsDir' on a null object reference #160
Comments
I'm having the same issue. On my own device (Huawei P30 Pro), there are no problems, headless tasks run just fine, but on an android 7.1.1 emulator and several other devices whenever the headless task is triggered, the application crashes with the exact same exception. |
@kanczler |
My apologies! flutter doctor:
|
Post the exact stacktrace |
Stack trace:
|
Boot the |
I have just used
I cannot reproduce this. How old is your app? You might have old code in your app from a previously generated flutter app that hasn't been properly upgraded. |
yes, our app is about 1 year old, be we regularly maintain it, especially updates to flutter and the project structure. |
If your app was generated quite a long time ago, I suggest using |
not an option. we made so many customizations to the project structure for flavors and such. it would take forever to get everything to this point again. |
Then I suggest you
You will want to migrate changes into your app. Are you using a custom |
This is not hard to migrate. |
we don't use a custom application.kt |
I made a mistake in the files to check. Corrected above (ie: |
ok, i looked at all the files, made changes so everything is exactly like in a newly created project, but the issue still exists. but what i did is take our current project and move back to flutter 1.20.0 and the issue is completely gone. it would be greatly appreciated if you could take another look. |
I have just created a fresh new Hello World app The app boots fine and simulated fetch events respond when app is running and headless.
|
i did the same and i know that it is working if you do it like this. but maybe flavors are the problem? All i can tell you is that the exact same code works flawless with flutter 1.20.0 but crashes with flutter 1.22.2 and that my android project looks like a newly created project just with all the necessary adaptions we need to make. |
The last reference to
|
yes, as i said. only headless crashes. non headless works perfectly fine |
i will try to reduce our project to a minimal example and share it with you, if that is ok? |
It seems this whole The docs say "Replaced by Ok, try this.
String appBundlePath = FlutterInjector.instance().flutterLoader().findAppBundlePath(); |
then i get this error when trying to run:
|
missing import? |
Did you open your When you add that line, the IDE will prompt you to add the required Add the following import io.flutter.FlutterInjector; |
still the same error :-/ |
I don’t know. You must be doing it wrong. Are you operating upon the /android app in Android Studio (not your flutter app)? |
with same error i meant that i get the same error when i run a headlessTask the compile worked |
i think falvors are the problem. i stripped everything from our project except flavors and use your example code for the main() |
Dart code is not responsible for your problem.
That's fine. |
@christocracy ok, after some more tinkering i found the solution:
and the corresponding line without that it will not work even though it should not be needed and was not needed when running flutter 1.20.x |
And before you provided an override, your <application
android:name="io.flutter.app.FlutterApplication" |
that seems to work as well. before we had no |
Generate a fresh new This is what your application element must look like when no override is provided: <application
android:name="io.flutter.app.FlutterApplication" |
@christocracy Since you link to it in your own setup guide and say
you might want to add the info above. |
This is solve my problem. |
ok, so it seems to be a framework issue. |
Had same problem and the provided solution resolved (Flutter 1.22.4). |
In HeadlessTask.java I have changed:
to
and it solved the problem of My AndroidManifest.xml does not have 'android:name' , as described in flutter upgrade guide. ...
so it should be safe. |
Not following this step during the migration fixed the issue with headless tasks. |
I had the same problem with flutter_alarm_manager when app was killed and flutter_alarm_manager wanted to fire an alarm, this solved the problem. |
This works on "Flutter 1.26.0-1.0.pre" for me. |
Can confirm that this worked for me also, using Flutter 1.25.0-8.3.pre. |
I am still having this issue with flutter 3.3.0 Anybody an idea why the flutterapplication is still needed. while the old migration page said to remove it? |
Where in the Setup or API docs are you directed to use |
please help, we got the same issue on 3.3.0 |
I just booted the /example app in this repo. I have see no issues. I suggest you implement the plugin in a fresh new hello_world app and familiarize yourself with the plugin Setup in a simple test-case, isolated from your application code.
|
Your Environment
0.6.0
Android
10.0
any
flutter info
,flutter doctor
):To Reproduce
Steps to reproduce the behavior:
Debug logs
Additional context
At first glance when you search via google this seems to be a bug in flutter itself
flutter/flutter#64458
but the fix is already on master and as you can see, i still run into this issue.
everything works fine as long as the app is still running and a backround task is triggered. only the headless one crashes with above error.
The text was updated successfully, but these errors were encountered: