我正在尝试使用flatter为Andriod应用程序构建一个发布应用程序包,
当我跑步时:
flutter build appbundle
我得到:
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument
types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3@775a0064]
我试图清理修复缓存,但它仍然不工作。弗利特医生很好。
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'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
androidExtensions {
experimental = true
}
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.Application"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile']
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:27.1.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
implementation 'com.facebook.android:facebook-login:[8.1)'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.fragment:fragment:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
Android\build.gradle文件:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google() // Google's Maven repository
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android\键。属性文件:
storePassword=123456789
keyPassword=123456789
keyAlias=upload
storeFile=C:\\Users\\User\\Documents\\Application\\upload-keystore.jks
满输出:
C:\Users\User\Documents\Application>flutter build appbundle
The plugin `flutter_open_whatsapp` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since
a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Kotlin plugin should be enabled before 'kotlin-android-extensions'
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\User\Documents\Application\android\app\build.gradle' line: 41
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3@27144de8]
* 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 2s
Running Gradle task 'bundleRelease'... 2,990ms
Gradle task bundleRelease failed with exit code 1
尝试在android studio中将/android目录作为一个项目打开,并在不使用flatter的情况下构建版本。
甚至可以尝试在项目中使用Java,看看它是否有效??
如果它有效,那么您的Kotlin版本可能会有一些问题。
我有一个基于gradle的Android项目,有4个子模块——两个库和两个应用程序。我试图通过将一些共享代码/配置移动到顶层build.gradle文件并使用来简化每个子模块的build.gradle文件。 文件系统结构如下所示: 问题是,如果我向子项目添加一个部分,那么gradle任务就会失败。例如,这是我的顶级 build.gradle 文件: 运行gradle返回这个: 出错的地方:评估根项
当我试图在android studio中打开pdf查看器时,我在pdf查看器中遇到了错误16,0https://github.com/barteksc/AndroidPdfViewer
分级同步消息为: 错误:(24,0)找不到Gradle DSL方法:“Android()”可能的原因: 我不太确定这个方法到底在哪里。如果它是位于应用程序的文件中的一个,我仍然不知道从这里到哪里去。感谢任何帮助。
错误:评估项目':app'时出现问题。 无法解析配置“classpath”的所有项目。找不到aapt2-proto.jar(com.android.tools.build:aapt2-proto:0.3.1).在以下位置进行了搜索:https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.
按照https://flutter.dev/docs/deployment/android#revisting-the-app-manifest中的所有指南进行操作后,在尝试构建AppBundle时仍然会出现错误。