long1eu / flutter_i18n

This plugin create a binding between your translations from .arb files and your Flutter app.
Apache License 2.0
251 stars 55 forks source link

Getting error in Plugin. #37

Closed as001622 closed 5 years ago

as001622 commented 5 years ago

I 'm getting following error when my application is started. And i18n file is not generated. kotlin.KotlinNullPointerException at eu.long1.flutter.i18n.files.FileHelpers.getI18nFile(FileHelpers.kt:20) at eu.long1.flutter.i18n.workers.I18nFileGenerator.generate(I18nFileGenerator.kt:54) at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1$lambda$1.compute(actions.kt:64) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:945) at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1.run(Timer.kt:150) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505)

hiperioncn commented 5 years ago

Same issue.

kika commented 5 years ago

Same.

kotlin.KotlinNullPointerException
    at eu.long1.flutter.i18n.files.FileHelpers.getI18nFile(FileHelpers.kt:20)
    at eu.long1.flutter.i18n.workers.I18nFileGenerator.generate(I18nFileGenerator.kt:54)
    at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1$lambda$1.compute(actions.kt:64)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:945)
    at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1.run(Timer.kt:150)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
kika commented 5 years ago

The reason is missing misc.xml in .idea directory (the project file).

hiperioncn commented 5 years ago

@kika Thanks. It works for me. Is it a bug of AS3.3?

kika commented 5 years ago

@hiperioncn or, it might become optional. Everything in my flutter project worked perfectly without this file, except for this plugin.

KingWu commented 5 years ago

@kika i get the same bug. but, where can i found misc.xml? my project is missing. What is the content of this file ?

benoitverstraete commented 5 years ago

@KingWu you can get this file in the example of the plugin : https://github.com/long1eu/flutter_i18n/blob/master/.idea/misc.xml

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ExternalStorageConfigurationManager" enabled="true" />
  <component name="NodePackageJsonFileManager">
    <packageJsonPaths />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
</project>
KingWu commented 5 years ago

@BenoitVerstraete Worked. Thx

long1eu commented 5 years ago

Is this still an issue?

benoitverstraete commented 5 years ago

@long1eu without the file misc.xml, the issue is still there.

mrruby commented 5 years ago

Yes its still an issue, but workaround works!

onitzschke commented 5 years ago

Still an issue but adding the .idea/misc.xml works.

noordawod commented 5 years ago

Duplicate of #43

titanseason commented 5 years ago

Is this issue fixed? I got the same error with: Flutter i18n plugin: version 1.0.1, Android Studio: version 3.3.2, Flutter: version 1.5.4

I copied the misc.xml file to .idea folder, and this plugin can generate i18n.dart.

But, I still think this is an issue

Nazacheres commented 5 years ago

Greetings, I got exactly the same issue, the only difference is that I am using Intellij IDEA. Adding misc.xml hasn't resolved the issue.

Nazacheres commented 5 years ago

Flutter i18n: 1.0.6-192 Intellij Idea: 2019.2

Stacktrace:

kotlin.KotlinNullPointerException
    at eu.long1.flutter.i18n.files.FileHelpers.getI18nFile(FileHelpers.kt:20)
    at eu.long1.flutter.i18n.workers.I18nFileGenerator.generate(I18nFileGenerator.kt:54)
    at eu.long1.flutter.i18n.actions.RebuildI18nFile$actionPerformed$1.run(RebuildI18nFile.kt:13)
    at com.intellij.openapi.command.WriteCommandAction.lambda$runWriteCommandAction$5(WriteCommandAction.java:368)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl$1.run(WriteCommandAction.java:125)
    at com.intellij.openapi.application.RunResult.run(RunResult.java:35)
    at com.intellij.openapi.command.WriteCommandAction.lambda$null$1(WriteCommandAction.java:264)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:994)
    at com.intellij.openapi.command.WriteCommandAction.lambda$performWriteCommandAction$2(WriteCommandAction.java:263)
    at com.intellij.openapi.command.WriteCommandAction.lambda$doExecuteCommand$4(WriteCommandAction.java:320)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:188)
    at com.intellij.openapi.command.WriteCommandAction.doExecuteCommand(WriteCommandAction.java:322)
    at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:263)
    at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:245)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:127)
    at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:368)
    at com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction(WriteCommandAction.java:360)
    at eu.long1.flutter.i18n.actions.RebuildI18nFile.actionPerformed(RebuildI18nFile.kt:13)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:265)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:256)
    at com.intellij.openapi.actionSystem.impl.ActionButton.actionPerformed(ActionButton.java:194)
    at com.intellij.openapi.actionSystem.impl.ActionButton.performAction(ActionButton.java:157)
    at com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:434)
    at java.desktop/java.awt.Component.processEvent(Component.java:6416)
    at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:873)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:461)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:460)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Nazacheres commented 5 years ago

Please, this is a critically important plugin for our team. What can we do to help to fix it? @noordawod

long1eu commented 5 years ago

until this is fixed, let me give you a workaround

  1. clone this repo git clone https://github.com/long1eu/flutter_i18n.git
  2. in your app root activate the generator page pub global activate --source path {ROOT for flutter_i18n}/flutter_l10n/
  3. run the package with watch param pub global run l10n_generator:main -w

Keep in mind that this generator produces the code in a new but compatible style.

NOTE: This is an experimental feature meant for quick recover when the plugin doesn't work.

Nazacheres commented 5 years ago

@long1eu Thank you very much, I will try and let you know!

Nazacheres commented 5 years ago

Ok, so actually, accidentally, I have figured out what was my problem. I have had a problem with the structure of files. At the beginning, I have had ~/FlutterProjects/myapp/root but at some point, I changed it to ~/FlutterProjects/myapp/myapp/root however, IntellijIDEA was still using .idea folder from the previous path. Fixing that, and adding the following misc.xml fixed the issue for me:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
  <component name="ProjectType">
    <option name="id" value="io.flutter" />
  </component>
</project>
long1eu commented 5 years ago

good to know

noordawod commented 5 years ago

Indeed good to know :)

dpedrinha commented 5 years ago

There's a misc.xml in my appfolder/.idea/ but it's a lot different from the one here.

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectType">
    <option name="id" value="io.flutter" />
  </component>
</project>

Also, closing the project and deleting the .idea folder should also fix this problem, right?

Anyway, new projects doesn't work anymore either. Create new flutter project, try extracting any string = Crash.

Problem is that I decided to update the plugin today.

This problem is back with the recent update and adding/changing the misc.xml file doesn't work now. YAY!

noordawod commented 5 years ago

This will be fixed after #103 is merged later today.

noordawod commented 5 years ago

Plugin v1.1.2 has been published to JetBrains, awaiting approval. It should be available during the day.