Description添加youtube_player_flutter v8.0.0 (链接:颤动)时,Flutter (颤动)应用程序无法使用以下错误日志构建:
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:97: error: package okhttp3 does not exist
import okhttp3.OkHttpClient;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:121: error: cannot find symbol
public OkHttpClient httpClient;
^
symbol: class OkHttpClient
location: class InAppWebView
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:24: error: package okhttp3 does not exist
import okhttp3.Request;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:25: error: package okhttp3 does not exist
import okhttp3.Response;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\Util.java:46: error: package okhttp3 does not exist
import okhttp3.OkHttpClient;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\Util.java:175: error: cannot find symbol
public static OkHttpClient getUnsafeOkHttpClient() {
^
symbol: class OkHttpClient
location: class Util
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\in_app_webview\InAppWebView.java:184: error: cannot find symbol
httpClient = new OkHttpClient().newBuilder().build();
^
symbol: class OkHttpClient
location: class InAppWebView
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:180: error: cannot find symbol
Request mRequest = new Request.Builder().url(urlHttps).build();
^
symbol: class Request
location: class ContentBlockerHandler
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:180: error: package Request does not exist
Request mRequest = new Request.Builder().url(urlHttps).build();
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:181: error: cannot find symbol
Response response = null;
^
symbol: class Response
location: class ContentBlockerHandler
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:231: error: cannot find symbol
Request mRequest = new Request.Builder().url(url).head().build();
^
symbol: class Request
location: class ContentBlockerHandler
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:231: error: package Request does not exist
Request mRequest = new Request.Builder().url(url).head().build();
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\content_blocker\ContentBlockerHandler.java:232: error: cannot find symbol
Response response = null;
^
symbol: class Response
location: class ContentBlockerHandler
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\Util.java:201: error: package OkHttpClient does not exist
OkHttpClient.Builder builder = new OkHttpClient.Builder();
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\Util.java:201: error: package OkHttpClient does not exist
OkHttpClient.Builder builder = new OkHttpClient.Builder();
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_inappwebview-5.3.2\android\src\main\java\com\pichillilorenzo\flutter_inappwebview\Util.java:210: error: cannot find symbol
OkHttpClient okHttpClient = builder
^
symbol: class OkHttpClient
location: class Util
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
16 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_inappwebview:compileDebugJavaWithJavac'.
> 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 27s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Configuration I有以下配置:
颤振医生输出:
[√] Flutter (Channel master, 2.3.0-17.0.pre.411, on Microsoft Windows [Version 10.0.19042.1052], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.57.1)
[√] Connected device (3 available)
Pubspec.yaml:
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.1
get_it:
google_fonts: ^2.1.0
shimmer: ^2.0.0
lottie: ^1.0.1
stacked: ^2.1.9
firebase_core: ^1.4.0
cloud_firestore: ^2.4.0
firebase_auth: ^3.0.1
firebase_analytics: ^8.2.0
pin_code_fields: ^7.2.0
geolocator: ^7.1.0
google_maps_flutter: ^2.0.6
geocoding: ^2.0.0
url_launcher: ^6.0.6
rflutter_alert: ^2.0.2
sms_autofill: ^2.0.0
carousel_slider: ^4.0.0
razorpay_flutter: ^1.2.6
flutter_tts: ^3.1.0
intl: ^0.17.0
webview_flutter: ^2.0.8
flutter_icons:
git:
url: https://github.com/adarsh-technocrat/flutter-icons
timelines: ^0.1.0
scrollable_positioned_list: ^0.1.10
in_app_review: ^2.0.2
share: ^2.0.4
connectivity: ^3.0.6
cached_network_image: ^3.0.0
youtube_player_flutter: ^8.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.9.0"
Build.gradle文件:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
技术细节:
已经尝试过解决方案
我已经在网上搜索了很多解决方案,也尝试了自己的一些技巧,但都徒劳无功。
下面是相同的列表:
environment: sdk: ">=2.12.0 <3.0.0"
。发布于 2021-07-26 20:01:50
按照推荐和稳定的方式安装Java 8。确保JRE和JDK都是8版。卸载您安装的任何其他版本。
发布于 2022-09-13 11:48:37
这是因为youtube_player_flutter
包使用的是flutter_inappwebview
。您可以在pub.dev上看到它,或者只在项目终端上运行命令$ flutter pub deps
。
要解决这个问题,您需要在fluttter_inappwebview
中的dependency_overrides下添加pubspec.yaml (如果您的pubspec.yaml中没有dependency_overrides部分,则在dependency部分下创建一个)。代码如下所示
dependency_overrides:
flutter_inappwebview:
git:
url: https://github.com/rshrc/flutter_inappwebview
ref: master
另外,不要忘记在android/app/ build.gradle file.Change中检查flutter_inappwebview
首选的file.Change。目前,它是minSdkVersion 17
。不要担心它是否高于flutter_inappwebview
的首选值。
https://stackoverflow.com/questions/68521217
复制相似问题