这可能是重复的,但我和其他一些人无法用我们的应用程序找到解决此构建问题的方案。
有一段时间,我们收到了关于不推荐使用的库的注释和警告,但这个新问题现在似乎完全阻止了构建(下面的完整输出(:
major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
一个重要的警告是flutter build appbundle --target-platform android-arm,android-arm64,android-x64
运行良好,只显示不推荐使用的注释。
我应该做什么来修复apk构建;如果问题出了,我该如何更新上面提到的编译器?如何更新已弃用的libs?
我正在使用带有Flutter和Dart插件的Visual Studio代码,这是我的flutter doctor
输出(没有任何警告相关(:
[√] 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:UsersfodorDocuments_AndroidFlutterSDKflutter
• 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:UsersfodorAppDataLocalAndroidsdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:Program FilesAndroidAndroid Studio1jrebinjava
• 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 FilesAndroidAndroid 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 FilesMicrosoft VS Code
• Flutter extension version 3.16.0
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
全输出:
PS C:UsersfodorDocuments_AndroidFlutter_FILC4filcnaplo> 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:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgdownloads_path_provider-0.1.0androidsrcmainjavaitnplacedownloadspathproviderDownloadsPathProviderPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgfile_picker-1.13.3androidsrcmainjavacommrflutterpluginfilepickerFileUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgimage_cropper-1.3.1androidsrcmainjavavnhunghdflutterpluginsimagecropperFileUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
warning: C:UsersfodorAppDataLocalAndroidsdkbuild-tools30.0.0core-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:UsersfodorAppDataLocalAndroidsdkbuild-tools30.0.0core-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:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgsqflite-1.3.1+2androidsrcmainjavacomtekartiksqfliteSqflitePlugin.java:1043: warning: [deprecation] Handler() in Handler has been deprecated
final Handler handler = new Handler();
^
1 warning
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.java:9: warning: [deprecation] AsyncTask in android.os has been deprecated
import android.os.AsyncTask;
^
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask in android.os has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask() in AsyncTask has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.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:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.java:121: warning: [deprecation] AsyncTask() in AsyncTask has been deprecated
new AsyncTask<Void, Void, Boolean>() {
^
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.java:128: warning: [deprecation] onPostExecute(Result) in AsyncTask has been deprecated
protected void onPostExecute(Boolean value) {
^
where Result is a type-variable:
C:UsersfodorAppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.5.12+2androidsrcmainjavaioflutterpluginssharedpreferencesMethodCallHandlerImpl.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:UsersfodorAppDataLocalAndroidsdkbuild-tools30.0.0core-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
谢谢你的帮助。
如果你仔细阅读输出,它会说(唯一(错误是有警告,并且由于编译选项-Werror,它们被视为错误。也许只是删除-Werror选项?
新的SDK版本一团糟,我发布这个答案时没有意识到问题的原因。无论哪种方式,这都应该有效:
把这个放在allprojects{}
部分之后的buid.gradle
中:
subprojects {
afterEvaluate {project ->
if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
android {
compileSdkVersion 29
buildToolsVersion '29.0.0'
}
}
}
}