該賞金過期5天。此問題的答案有資格獲得 400聲望獎勵。 斯科布希望引起更多人對這個問題的關注。
我正在為 android 構建一個 flutter 應用程式。
我從...更新了gradle構建工具版本
classpath 'com.android.tools.build:gradle:3.5.0'
到
classpath 'com.android.tools.build:gradle:4.1.3'
現在我收到構建錯誤...
Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/user/src/myapp/build/app/intermediates/packaged_manifests/release/AndroidManifest.xml:34: AAPT: error: attribute android:usesPermissionFlags not found.
我的 build.gradle 如下...
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
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
}
我的應用程式/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: 'kotlin-android'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs = 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.me.myapp"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
我的 gradle-wrapper.properties 如下...
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="tenera_provision"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
uj5u.com熱心網友回復:
檢查 android/app 中的 build.gradle
compileSdkVersion 30 minSdkVersion 16 targetSdkVersion 30
如果這沒有解決,那么您可能在 android/app/src/main/AndroidManifest.xml 中的 android manifest 中缺少權限
uj5u.com熱心網友回復:
錯誤資訊一般來自 AAPT2。
可以看到,這個屬性從 API 級別 17 開始就存在了。
出于除錯目的,合并的AndroidManifest.xml@line 34 會更有趣,因為android:usesPermissionFlags即使來自哪里的問題仍然存在,因為insideAndroidManifest.xml模塊:app沒有這條線并且合并版本需要從某個地方獲取它 - 這只能是另一個模塊或某個AAR庫。
buildToolsVersion "30.0.3"應該可以作業,但由于沒有其他任何宣告,這仍然應該是類似的......盡管如此,Android Studio(存檔)的版本也起作用(它需要匹配 Gradle 插件的版本,即4.1.3,與 Gradle 4.4)... 或者對于當前的“北極狐”,這將是7.0.3,使用 Gradle 7.2(您正在構建一個遺留專案)。
aapt2 version 應該回傳:
Android 資產打包工具 (aapt) 2.19-6966805
這將是包含要使用的版本的表格。
實際上,Gradle 太新的可能性也很小。
順便說一句......我什至可以證明這是一個假設(除了:clean任務通常駐留在根build.gradle而不是模塊中build.gradle,這是一個潛在的問題):
task clean(type: Delete) {
delete rootProject.buildDir
}
這表明,./build正在被洗掉,但不是./app/build。我什至會走得更遠,不僅 delete ./build,而且~/.gradle/cache. 如果應該有更多的 Java/Kotlin 模塊存在,請確保其中沒有一個是使用過時的buildToolsVersion.
將其保留在 module 中時build.gradle,應將其全部洗掉:
task clean(type: Delete) {
delete rootProject.buildDir
delete project.buildDir
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/322970.html
