Reputation: 21
I am struggling a whole day to find out how to build apk. This one is suddenly happened. I have no idea why, there is no problem before. Here is the error while I am doing
flutter build apk
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unity_mediation:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR:/Users/bobbyjulian/.gradle/caches/transforms-3/a68f5ae822254b02ed9aba74a762d661/transformed/core-1.9.0/res/values/values.xml:104:5-113:25: AAPT: error: resource android:attr/lStar not found.
Here is my /app/src/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 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
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.thesimlife.thesimlife"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.unity3d.mediation:adcolony-adapter:1.0.0"
implementation "com.unity3d.mediation:applovin-adapter:1.0.0"
implementation "com.unity3d.mediation:vungle-adapter:1.0.1"
implementation "com.unity3d.mediation:facebook-adapter:1.0.0"
implementation "com.unity3d.mediation:admob-adapter:1.0.0"
}
build.gradle (I have changed the kotlin_version but it has no luck)
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
maven {
url 'https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/'
}
}
dependencies {
//classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/'
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The weird thing, I can build apk debug with
flutter build apk --debug
Running Gradle task 'assembleDebug'... 46.2s Built build/app/outputs/flutter-apk/app-debug.apk.
and then the appbundle
flutter build appbundle
Running Gradle task 'bundleRelease'... 31.2s ✓ Built build/app/outputs/bundle/release/app-release.aab (45.4MB).
Result for
flutter doctor -v
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.1 22C65 darwin-arm64, locale
en-ID)
• Flutter version 3.7.12 on channel stable at
/Users/bobbyjulian/Desktop/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4d9e56e694 (3 weeks ago), 2023-04-17 21:47:46 -0400
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /Users/bobbyjulian/Library/Android/sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.70.1)
• VS Code at /Users/bobbyjulian/Downloads/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• iPhone 14 Pro (mobile) • 507F3DEA-5963-452F-8CB0-10969F21BB18 • ios
• com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
• macOS (desktop) • macos •
darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome •
web-javascript • Google Chrome 112.0.5615.137
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I really appreciate any help.
Resolve build apk issues!
Upvotes: 1
Views: 599
Reputation: 125
"androidx.core:core-ktx" version might be the issue. Make sure to have 1.6.0 or latest version of that. Do clean and build after updating it.
Also if require, force all dependency to use same version.
implementation 'androidx.core:core-ktx:1.10.0
'
Upvotes: 0