This is the 11th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021

Today, I encountered a very bad problem. After a long time of investigation and searching for information on the Internet, I failed to solve it. Finally, I had to settle down to analyze the Log and the solution ideas on the Internet to find the problem

Problem description

Error when running a previously OK Flutter project, the Log looks like this:

* What went wrong: Execution failed for task ':firebase_core:javaPreCompileDebug'. > Could not resolve all files for configuration 'xxx'. >  Could not find xxxxx. Searched in the following locations: https://xxxx * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 2sCopy the code

Local Flutter doctor-v checked and found nothing wrong

Online research

Then a simple look at the Log probably clear is a library failed to find the reason, and then because of laziness ~ directly online search solution.

The most common solution is to add a Maven address to build. Gradle in the Android directory, and then get the library again.

I tried most of the methods, rerequested the cache N times, reran the code N times and still got an error…

Decided to make a cup of tea and take a break for inspiration

Problem solving

After squinting for a while, I felt that this problem might be my individual case, not a problem that can be solved directly by copy.

Combined with the above solution and error Log and my little inspiration, I think the problem is my Maven repository configuration and flutter library search. Then I went through all the error libraries in detail and found that they all seemed to be internal component libraries. The reason for this should be the configuration of flutter/ DART

Then I went to the environment variable configuration and found that the path of the official SDK was ahead of the path of the company SDK, so I suddenly switched them, reopened the IDE, and started running again with confidence

And then… The error is the same, but the flutter doctor -v shows that the flutter has switched to the company’s SDK. Why is it wrong? Is there a Bug? After another cup of tea and a bit of inspiration, I started a global search for the company library name and found that both the.package file and the cache address of.flutter-plugins were still the path of the official SDK….

Why? Suddenly I remember that my pub get operation is implemented by clicking the IDE directly. Is it possible that the IDE has configured my bin path? Sure enough, Settings -> Languages&FrameWork -> Dart finds that the path configured is still the official SDK and changes back to the company SDK

Finally, the last RUN is reexecuted, OK~build is successful, the problem is resolved successfully!

review

  • If you have a problem, analyze the Log carefully. It may not solve the problem directly, but it will help you to think more broadly
  • Online solutions in addition to direct copy, but also to try to analyze the solution
  • If you encounter a bottleneck, you can drink some tea and take a walk. Maybe inspiration will come