Issue
This may be a duplicate, but I and some others have been unable to find a solution to this build problem with our app.
For a while now we were getting notes and warnings on deprecated libraries, but it seems like this new problem is now completely preventing the build (full output below):
major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
An important caveat is that flutter build appbundle --target-platform android-arm,android-arm64,android-x64
works fine, just showing the deprecated notes.
What should I do to fix the apk build; how do I update the compiler as mentioned above, if that turns out to be the problem? How do I update the deprecated libs?
I'm using Visual Studio Code with the Flutter and Dart plugins, this is my flutter doctor
output (none of the warnings are relevant):
[√] Flutter (Channel beta, 1.22.0-12.1.pre, on Microsoft Windows [Version 10.0.18363.1139], locale hu-HU)
• Flutter version 1.22.0-12.1.pre at C:\Users\fodor\Documents\_Android\FlutterSDK\flutter
• Framework revision 8b3760638a (7 weeks ago), 2020-09-15 17:47:13 -0700
• Engine revision 4654fc6cf6
• Dart version 2.10.0 (build 2.10.0-110.3.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\fodor\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio1
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code, 64-bit edition (version 1.50.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.16.0
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
Full output:
PS C:\Users\fodor\Documents\_Android\Flutter\_FILC4\filcnaplo> 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
Note: C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\downloads_path_provider-0.1.0\android\src\main\java\it\nplace\downloadspathprovider\DownloadsPathProviderPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.13.3\android\src\main\java\com\mr\flutter\plugin\filepicker\FileUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\image_cropper-1.3.1\android\src\main\java\vn\hunghd\flutter\plugins\imagecropper\FileUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
warning: C:\Users\fodor\AppData\Local\Android\sdk\build-tools\30.0.0\core-lambda-stubs.jar(java/lang/invoke/LambdaMetafactory.class): major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
1 warning
warning: C:\Users\fodor\AppData\Local\Android\sdk\build-tools\30.0.0\core-lambda-stubs.jar(java/lang/invoke/LambdaMetafactory.class): major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
1 warning
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\sqflite-1.3.1+2\android\src\main\java\com\tekartik\sqflite\SqflitePlugin.java:1043: warning: [deprecation] Handler() in Handler has been deprecated
final Handler handler = new Handler();
^
1 warning
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:9: warning: [deprecation] AsyncTask in android.os has been deprecated
import android.os.AsyncTask;
^
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask in android.os has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask() in AsyncTask has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:123: warning: [deprecation] doInBackground(Params...) in AsyncTask has been deprecated
protected Boolean doInBackground(Void... voids) {
^
where Params,Result are type-variables:
Params extends Object declared in class AsyncTask
Result extends Object declared in class AsyncTask
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask() in AsyncTask has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:128: warning: [deprecation] onPostExecute(Result) in AsyncTask has been deprecated
protected void onPostExecute(Boolean value) {
^
where Result is a type-variable:
C:\Users\fodor\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.5.12+2\android\src\main\java\io\flutter\plugins\sharedpreferences\MethodCallHandlerImpl.java:131: warning: [deprecation] execute(Params...) in AsyncTask has been deprecated
}.execute();
where Params,Progress,Result are type-variables:
Params extends Object declared in class AsyncTask
Progress extends Object declared in class AsyncTask
Result extends Object declared in class AsyncTask
7 warnings
warning: C:\Users\fodor\AppData\Local\Android\sdk\build-tools\30.0.0\core-lambda-stubs.jar(java/lang/invoke/LambdaMetafactory.class): major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
error: warnings found and -Werror specified
1 error
1 warning
* What went wrong:
Execution failed for task ':video_player:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 1m 37s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 98,4s
Gradle task assembleRelease failed with exit code 1
Thank you for your help.
Solution
The new SDK version messes with stuff, and I'm posting this answer without being aware of the route cause of the problem. Either way, this should work:
Put this in your buid.gradle
after the allprojects{}
section:
subprojects {
afterEvaluate {project ->
if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
android {
compileSdkVersion 29
buildToolsVersion '29.0.0'
}
}
}
}
Answered By - RedyAu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.