Description
There is an issue with building when there's incompatibility in one package, and so the tool tries "using Jetfier to solve the incompatibility", it will get "SDK location not found." error!
Then, setting a local.properties in package's directory in .pub-cache will solve this issue, but then the same error ("SDK location not found.") will appear for other packages! (and it will be a pain to add a "local.properties" file to every package's directory because of a problem in just one package.
It seems to me like an error caused by mistake in updating PATH when compiling different packages.
below is the complete error I'm getting, where "flutter_twitter_login" package had a problem, the tool used Jetfier to solve it, then it got the "SDK location not found." error, then I added a "local.properties" file to flutter_twitter_login package's directory, then the "SDK location not found." error appeared for "url_launcher" package, which normally didn't make this error if I didn't use flutter_twitter_login package.
flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the
APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_twitter_login:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/blahblah/.gradle/caches/transforms-2/files-2.1/0a271e99b6771ad4a84318244d532fb7/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/blahblah/.gradle/caches/transforms-2/files-2.1/0a271e99b6771ad4a84318244d532fb7/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 17s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 18.2s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to
solve the incompatibility.
Building plugin flutter_twitter_login...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2.2s
✓ Built build/app/outputs/repo.
Building plugin url_launcher...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2.3s
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'url_launcher'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/blahblah/Codes/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.2/android/local.properties'.
* 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 2s
The plugin url_launcher could not be built due to the issue above.
flutter doctor:
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E266, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.43.2)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
here, if I remove the "flutter_twitter_login" package from my project's pubsec, which is causing the problem because of an incompatibility, build will success.
On the other hand, if I remove the "url_launcher" package either, build will succeed again! ( "flutter_twitter_login" will fail at first like above, but after the toll trying to use Jetfier, the whole project will build successfuly (if I place the local.properties file in its directory).
the content of the local.properties file I put in the flutter_twitter_login 's directory was the same as my project's local.properties file:
sdk.dir=/Users/blahblah/Library/Android/sdk
flutter.sdk=/Users/blahblah/Codes/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1