添加youtube_player_Flatter v8.0.0时的说明(链接:https://github.com/sarbagyastha/youtube_player_flutter)Flutter(android)应用程序无法生成,错误日志如下:
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)
配置我有以下配置:
Flutter医生输出:
[√] 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
}
技术细节:
设备:华硕z01rd(移动式)
操作系统:安卓
安卓10版
已经尝试过的解决方案
我已经在互联网上搜索了很多解决方案,也尝试了一些我自己的技巧,但都没有成功。
以下是相同的列表:
尝试了此处提到的解决方案:https://github.com/sarbagyastha/youtube_player_flutter/issues/490
我试着升级gradle版本。
我试着运行干净的安装。
我尝试将整个应用程序升级到空安全,因此使用 environment: sdk: ">=2.12.0 <3.0.0"
尝试通过pubspec.yaml显式安装Flatter_inappwebview插件。
尝试删除一些我认为可能存在冲突的其他现有依赖项(如webview_Flatter插件)。
已尝试将所有依赖项列表升级到最新版本。
1条答案
按热度按时间2eafrhcq1#
安装Java8,因为它是推荐和稳定的。确保jre和jdk都应该是版本8。卸载您安装的任何其他版本。