Skip to content

Commit

Permalink
all: clean up, print remedy *after* error message
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Oct 16, 2024
1 parent 7e03028 commit 562f95e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
15 changes: 15 additions & 0 deletions android/android.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright(C) 2019-2024 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license file distributed with this software package
module android

pub const default_app_name = $d('vab:default_app_name', 'V Test App')
pub const default_package_id = $d('vab:default_package_id', 'io.v.android')
pub const default_activity_name = $d('vab:default_activity_name', 'VActivity')
pub const default_package_format = $d('vab:default_package_format', 'apk')
pub const default_min_sdk_version = int($d('vab:default_min_sdk_version', 21))
pub const default_base_files_path = get_default_base_files_path()
pub const supported_package_formats = ['apk', 'aab']
pub const supported_lib_folders = ['armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
pub const mipmap_icon_sizes = [192, 144, 96, 72, 48]! // xxxhdpi, xxhdpi, xhdpi, hdpi, mdpi

pub type OptionTypes = CompileOptions | PackageOptions | DeployOptions
10 changes: 0 additions & 10 deletions android/package.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import vab.android.env
import vab.android.sdk
import vab.android.util

pub const default_app_name = $d('vab:default_app_name', 'V Test App')
pub const default_package_id = $d('vab:default_package_id', 'io.v.android')
pub const default_activity_name = $d('vab:default_activity_name', 'VActivity')
pub const default_package_format = $d('vab:default_package_format', 'apk')
pub const default_min_sdk_version = int($d('vab:default_min_sdk_version', 21))
pub const default_base_files_path = get_default_base_files_path()
pub const supported_package_formats = ['apk', 'aab']
pub const supported_lib_folders = ['armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
pub const mipmap_icon_sizes = [192, 144, 96, 72, 48]! // xxxhdpi, xxhdpi, xhdpi, hdpi, mdpi

// PackageFormat holds all supported package formats
pub enum PackageFormat {
apk
Expand Down
3 changes: 0 additions & 3 deletions cli/options.v
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,6 @@ To use a specific version you can use `${exe_short_name} --build-tools "<version
}
exit(1)
}

// Give notices for know mismatches of various things
notify_known_errors(opt)
}

// resolve_output modifies `Options.output` according to what `Option.input` contains.
Expand Down
36 changes: 29 additions & 7 deletions cli/remedy.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,41 @@ module cli

import semver
import vab.util
import vab.android
import vab.extra

// notify_known_errors notifies when know mismatches of various things is detected.
pub fn notify_known_errors(opt Options) {
if opt.api_level.i16() >= 33 {
// doctor_remedy notifies of known errors and mismatches of various Android SDK/NDK bugs, if detected.
pub fn doctor_remedy(opts android.OptionTypes, err_str string) {
match opts {
android.PackageOptions {
notify_known_package_errors(opts, err_str)
}
else {}
}
}

fn callsite_extra_command(cmd string) string {
if cmd.starts_with(extra.command_prefix + '-') {
return '${extra.command_prefix} ${cmd.all_after(extra.command_prefix + '-')}'
}
return cmd
}

fn notify_known_package_errors(opt android.PackageOptions, err_str string) {
if opt.api_level.i16() >= 35 {
if build_tools_semantic_version := semver.from(opt.build_tools) {
if build_tools_semantic_version.satisfies('<35.0.0') {
build_tools_version := '34.0.0'
if build_tools_semantic_version.satisfies('<${build_tools_version}') {
symptoms_aab := "\taapt2 E 10-15 19:10:38 93691 93691 LoadedArsc.cpp:96] RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data.
\taapt2 E 10-15 19:10:38 93691 93691 ApkAssets.cpp:500] Failed to load 'resources.arsc' in APK '.../platforms/android-35/android.jar'."
symptoms_apk := "\taapt E 10-15 18:51:31 89712 89712] Entry offset at index 1335 points outside the Type's boundaries
\t.../AndroidManifest.xml:13: error: Error: No resource found that matches the given name (at 'theme' with value '@android:style/Theme.NoTitleBar.Fullscreen').
\t.../res/values/styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'."
symptoms := if opt.package_format == 'aab' { symptoms_aab } else { symptoms_apk }
util.vab_notice('Using build-tools < 35.0.0 with Android API level >= 33 is known to cause package build errors',
details: 'Symptoms output:\n${symptoms}\nIt can usually be fixed by installing and using build-tools >= 35.0.0\nTry:\n\tvab install "build-tools;35.0.0"'
symptoms := if opt.format == .aab { symptoms_aab } else { symptoms_apk }
util.vab_notice('Using build-tools < ${build_tools_version} with Android API level >= ${opt.api_level} is known to cause package build errors',
details:
'Symptoms:\n${symptoms}\nIt can usually be fixed by installing and using build-tools >= ${build_tools_version}' +
'\nTry:\n\tvab install "build-tools;${build_tools_version}"\n\t${callsite_extra_command(exe_short_name)} --build-tools "${build_tools_version}" ...'
)
}
}
Expand Down
1 change: 1 addition & 0 deletions vab.v
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ fn main() {
}
android.package(pck_opt) or {
util.vab_error('Packaging did not succeed', details: '${err}')
cli.doctor_remedy(pck_opt, err.msg()) // Suggest possible fixes to known errors
exit(1)
}

Expand Down

0 comments on commit 562f95e

Please sign in to comment.