任何人都可以帮我解决这个错误吗(我什至有一个 ListViews 在移动设备上没有显示任何内容(flutter build apk),但在网络上它工作正常(flutter build web 和 flutter run on web)?
它要求版本1.6.0,但我不知道哪些gradle版本与之兼容,我尝试了一切。
这些也给了我同样的东西:
kotlin-stdlib
kotlin-stdlib-jdk7
kotlin-stdlib-jdk8
我构建的 apk 可以工作,但不知怎的,其中一个列表视图实际上不起作用(其他 listViews、GridViews 和应用程序的其余部分工作正常)!
Flutter 版本(+ JDK 11): (Android Studio Flamingo 2022.2.1补丁2)
Flutter 3.7.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 62bd79521d (3 months ago) • 2023-03-30 10:59:36 -0700
Engine • revision ec975089ac
Tools • Dart 2.19.6 • DevTools 2.20.1
android/build.gradle:
buildscript {
ext.kotlin_version = '1.7.20'
// works : ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
// Add the dependency for the Google services Gradle plugin :
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/gradle/wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
android/app/build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 33
// I added this because of the flutter build apk issue
//ndkVersion "25.1.8937393"
//compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
// old 1.8
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.elearning_provider"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
targetSdkVersion 33
//multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
//
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:31.5.0')
implementation 'com.google.firebase:firebase-analytics'
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
// old: implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// old: implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// old: implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
终端(错误):
PS C:\Users\Barack\Desktop\Final-elearny> flutter build apk --split-per-abi
Building with sound null safety
Note: C:\Users\Barack\AppData\Local\Pub\Cache\hosted\pub.dev\cloud_firestore-4.8.1\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestoreMessageCodec.java
uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\Barack\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_windowmanager-0.2.0\android\src\main\java\io\adaptant\labs\flutter_windowmanager\FlutterWindowManagerPlugin.java us
es or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
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.
e: C:/Users/Barack/.gradle/caches/transforms-3/0289e7d586838872ea3cc5ef2b0208b5/transformed/jetified-activity-1.7.2/jars/classes.jar!/META-INF/activity_release.kotlin_module: Module wa
s compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/Barack/.gradle/caches/transforms-3/bbd170a816c85b7600f21cb0bf06a8e6/transformed/lifecycle-livedata-2.6.1/jars/classes.jar!/META-INF/lifecycle-livedata_release.kotlin_module
: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/Barack/.gradle/caches/transforms-3/564fb61e5651867636042f1aba0f676b/transformed/lifecycle-viewmodel-2.6.1/jars/classes.jar!/META-INF/lifecycle-viewmodel_release.kotlin_modu
le: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
Running Gradle task 'assembleRelease'... 511.4s
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (12.8MB).
√ Built build\app\outputs\flutter-apk\app-arm64-v8a-release.apk (13.0MB).
√ Built build\app\outputs\flutter-apk\app-x86_64-release.apk (13.2MB).
PS C:\Users\Barack\Desktop\Final-elearny>
pubspec.yaml:
name: elearning
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 12.8.0 #0+1
environment:
sdk: '>=2.19.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
get_it: ^7.2.0
dob_input_field: ^2.0.0
file_picker: ^5.2.7
english_words: ^4.0.0
emailjs: ^1.1.0
youtube_player_iframe_plus: ^2.3.2
video_player: ^2.6.1
video_player_web: ^2.0.16
http: ^0.13.6
dio: ^5.1.1
photo_view: 0.14.0
youtube_player_iframe: ^2.3.0
# EditTraining
dropdown_button2: ^2.1.4
charts_flutter: ^0.12.0
# Login new UI
#rive: ^0.11.3
flutter_image_compress: ^2.0.3
#webview_flutter: ^2.0.13
######### NEW :
auto_size_text: 3.0.0
cached_network_image: ^3.2.3
flutter_animate: ^4.2.0
flutter_cache_manager: 3.3.0
font_awesome_flutter: ^10.4.0
from_css_color: 2.0.0
#go_router: ^8.1.0
google_fonts: ^4.0.4
html_editor_enhanced: ^2.5.1
intl: 0.17.0
json_path: ^0.5.2
page_transition: ^2.0.9
provider: 6.0.4
shared_preferences: ^2.1.2
sqflite: ^2.2.8+4
timeago: ^3.3.0
url_launcher: ^6.1.11
firebase_core: ^2.5.0
firebase_auth: ^4.2.6
cloud_firestore: ^4.4.4
lottie: ^2.2.0
google_sign_in: ^6.0.1
google_sign_in_web: ^0.12.0+2
flutter_windowmanager: ^0.2.0
image_picker: ^0.8.7+1
firebase_storage: ^11.1.0
cupertino_icons: ^1.0.0
universal_html: ^2.2.1
shimmer: ^2.0.0
flutter_html: ^3.0.0-beta.2
flutter_html_iframe: ^3.0.0-beta.2
flutter_widget_from_html: ^0.10.0
# Lessons - HtmlEditor
#flutter_html: ^2.1.2
#flutter_html: 3.0.0-alpha.5
webview_flutter_android: ^3.8.0
webview_flutter_platform_interface: ^2.3.1
webview_flutter_wkwebview: ^3.5.0
sticky_headers: ^0.3.0+2
#vdocipher_flutter: ^2.2.6
dependency_overrides:
provider:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- lib/images/
- lib/images/default_profile_image.png
- lib/images/login-page-lock-lottie-anim.json
- assets/fonts/
- assets/images/
- assets/videos/
- assets/audios/
- assets/lottie_animations/
- assets/pdfs/