Generate APK Cordova AS
August 8, 2025 · AI Conversations
—
### ✅ 1. **Ensure Android platform is added to Cordova**
In your Cordova project folder:
cordova platform add android
—
### ✅ 2. **Build the Cordova Android project**
cordova build android
This generates the Android project inside:
<your-cordova-project>/platforms/android/
—
### ✅ 3. **Open project in Android Studio**
1. Launch **Android Studio**.
2. Select **"Open an existing project"**.
3. Navigate to:
<your-cordova-project>/platforms/android/
4. Open this folder.
—
### ✅ 4. **Wait for Gradle sync to finish**
Android Studio will detect the `build.gradle` files and sync the project. Ensure the correct SDKs are installed.
—
### ✅ 5. **Generate APK**
Once Gradle sync completes:
– Go to **Build > Build Bundle(s) / APK(s) > Build APK(s)**.
– After the build completes, click the **"locate"** link or find your APK at:
platforms/android/app/build/outputs/apk/debug/app-debug.apk
—
### ✅ (Optional) Generate Signed APK
For release builds:
1. Go to **Build > Generate Signed Bundle/APK**.
2. Select **APK**, then **Next**.
3. Use an existing keystore or create a new one.
4. Choose **release** build type.
5. Finish to generate a signed APK.
—
Would you like help automating this with a build script or CI pipeline?
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
———–
* Where:
Script '/home/admin1/cordova/new/circusscanner/platforms/android/cordova-plugin-qrscanner/scanner-qrscanner.gradle' line: 6
* What went wrong:
A problem occurred evaluating script.
> Could not find method compile() for arguments [com.journeyapps:zxing-android-embedded:3.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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.
==============================================================================
2: Task failed with an exception.
———–
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* 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.
==============================================================================
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '–warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 2s
Command failed with exit code 1: /home/admin1/cordova/new/circusscanner/platforms/android/tools/gradlew cdvBuildDebug
—
### ❌ **Issue 1: Gradle `compile` is deprecated**
In this file:
cordova-plugin-qrscanner/scanner-qrscanner.gradle
You're using:
compile 'com.journeyapps:zxing-android-embedded:3.3.0'
✅ **Fix**: Change `compile` to `implementation`
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
> The `compile` keyword was removed in Gradle 7+. Use `implementation` instead.
—
### ❌ **Issue 2: `compileSdkVersion` is missing**
The error message:
compileSdkVersion is not specified. Please add it to build.gradle
✅ **Fix**:
Edit the file:
platforms/android/app/build.gradle
And add or fix this inside `android` block:
android {
compileSdkVersion 33 // or whatever version you have installed
defaultConfig {
targetSdkVersion 33
minSdkVersion 21
// ...
}
}
> You can check installed SDKs in Android Studio → SDK Manager.
—
### ✅ Quick Fix Steps Recap
1. **Edit `scanner-qrscanner.gradle`:**
– Change `compile` to `implementation`.
2. **Edit `app/build.gradle`:**
– Make sure `compileSdkVersion`, `targetSdkVersion`, and `minSdkVersion` are set.
3. **Sync & Rebuild:**
– Run:
cordova clean android
cordova build android
—
Would you like me to modify and give you the fixed `scanner-qrscanner.gradle` file content directly?
—
### ✅ Option 1: Check Installed SDK Versions (Recommended)
#### Using Android Studio:
1. Open Android Studio.
2. Go to **Tools > SDK Manager**.
3. Under the **"SDK Platforms"** tab, you'll see a list of installed Android SDKs.
4. The **highest installed version** (e.g., Android 13 = API 33) is safe to use for `compileSdkVersion`.
—
### ✅ Option 2: Check from Terminal (Linux/macOS)
Run:
ls $ANDROID_HOME/platforms/
Or if `ANDROID_HOME` is not set:
ls ~/Android/Sdk/platforms/
Output example:
android-30
android-31
android-33
So you can use:
compileSdkVersion 33
—
### ✅ Option 3: Let Android Studio Suggest It
If you open the Cordova project via Android Studio:
– It may automatically prompt you to "Update compileSdkVersion" if it's missing or incompatible.
—
### ✅ Final Code Sample
android {
compileSdkVersion 33
defaultConfig {
targetSdkVersion 33
minSdkVersion 21
}
}
—
Let me know if you want to detect this programmatically or set it automatically during Cordova build.
### ✅ Update your `build.gradle` like this:
In `platforms/android/app/build.gradle`, modify the `android` block:
android {
compileSdkVersion 35
defaultConfig {
applicationId "your.package.name"
minSdkVersion 21
targetSdkVersion 35
versionCode 1
versionName "1.0"
}
// ...rest of your config
}
> Replace `"your.package.name"` with your actual app ID if needed.
—
Once done:
cordova clean android
cordova build android
This should resolve the `compileSdkVersion` error.
Need help fixing the plugin's `scanner-qrscanner.gradle` too?
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
apply plugin: 'com.android.application'
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
apply plugin: 'kotlin-android'
if(!cdvHelpers.isVersionGreaterThanEqual(cordovaConfig.KOTLIN_VERSION, '1.8.0')) {
println "Kotlin version < 1.8.0 detected. Applying kotlin-android-extensions plugin."
apply plugin: 'kotlin-android-extensions'
}
}
buildscript {
apply from: '../CordovaLib/cordova.gradle'
// Checks if the kotlin version format is valid.
if(cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
if(!cdvHelpers.isVersionValid(cordovaConfig.KOTLIN_VERSION)) {
throw new GradleException("The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION}) does not appear to be a valid version.")
}
}
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${cordovaConfig.KOTLIN_VERSION}"
}
if(cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
// Checks if the kotlin version format is valid.
if(!cdvHelpers.isVersionValid(cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION)) {
throw new GradleException("The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version.")
}
// Create the Google Services classpath and set it.
String gradlePluginGoogleServicesClassPath = "com.google.gms:google-services:${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}"
println "Adding classpath: ${gradlePluginGoogleServicesClassPath}"
classpath gradlePluginGoogleServicesClassPath
}
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}
task wrapper(type: Wrapper) {
gradleVersion = cordovaConfig.GRADLE_VERSION
}
// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
apply from: '../CordovaLib/cordova.gradle'
// Sets the versionCode to the given value.
if (!project.hasProperty('cdvVersionCode')) {
cdvVersionCode = null
}
// Whether to build architecture-specific APKs.
if (!project.hasProperty('cdvBuildMultipleApks')) {
cdvBuildMultipleApks = null
}
// Whether to append a 0 "abi digit" to versionCode when only a single APK is build
if (!project.hasProperty('cdvVersionCodeForceAbiDigit')) {
cdvVersionCodeForceAbiDigit = null
}
// .properties files to use for release signing.
if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
cdvReleaseSigningPropertiesFile = null
}
// .properties files to use for debug signing.
if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
cdvDebugSigningPropertiesFile = null
}
// Set by build.js script.
if (!project.hasProperty('cdvBuildArch')) {
cdvBuildArch = null
}
// Plugin gradle extensions can append to this to have code run at the end.
cdvPluginPostBuildExtras = []
}
// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-qrscanner/scanner-qrscanner.gradle"
// PLUGIN GRADLE EXTENSIONS END
def hasBuildExtras1 = file('build-extras.gradle').exists()
if (hasBuildExtras1) {
apply from: 'build-extras.gradle'
}
def hasBuildExtras2 = file('../build-extras.gradle').exists()
if (hasBuildExtras2) {
apply from: '../build-extras.gradle'
}
// Apply updates that might come from build-extra.
privateHelpers.applyCordovaConfigCustomization()
// Set property defaults after extension .gradle files.
if (ext.cdvDebugSigningPropertiesFile == null && file('../debug-signing.properties').exists()) {
ext.cdvDebugSigningPropertiesFile = '../debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.properties').exists()) {
ext.cdvReleaseSigningPropertiesFile = '../release-signing.properties'
}
// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
def computeBuildTargetName(debugBuild) {
def ret = 'assemble'
if (cdvBuildMultipleApks && cdvBuildArch) {
def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
}
return ret + (debugBuild ? 'Debug' : 'Release')
}
// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
return computeBuildTargetName(true)
}
task cdvBuildRelease
cdvBuildRelease.dependsOn {
return computeBuildTargetName(false)
}
task cdvPrintProps {
doLast {
println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
println('cdvVersionCode=' + cdvVersionCode)
println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
println('cdvSdkVersion=' + cdvSdkVersion)
println('cdvMinSdkVersion=' + cdvMinSdkVersion)
println('cdvMaxSdkVersion=' + cdvMaxSdkVersion)
println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
println('cdvBuildArch=' + cdvBuildArch)
println('computedVersionCode=' + android.defaultConfig.versionCode)
println('cdvAndroidXAppCompatVersion=' + cdvAndroidXAppCompatVersion)
println('cdvAndroidXWebKitVersion=' + cdvAndroidXWebKitVersion)
android.productFlavors.each { flavor ->
println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
}
}
}
android {
namespace cordovaConfig.PACKAGE_NAMESPACE
buildFeatures {
buildConfig true
}
defaultConfig {
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId cordovaConfig.PACKAGE_NAMESPACE
minSdkVersion cordovaConfig.MIN_SDK_VERSION
if (cordovaConfig.MAX_SDK_VERSION != null) {
maxSdkVersion cordovaConfig.MAX_SDK_VERSION
}
targetSdkVersion cordovaConfig.SDK_VERSION
compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION
}
lintOptions {
abortOnError false
}
buildToolsVersion cordovaConfig.BUILD_TOOLS_VERSION
// This code exists for Crosswalk and other Native APIs.
// By default, we multiply the existing version code in the
// Android Manifest by 10 and add a number for each architecture.
// If you are not using Crosswalk or SQLite, you can
// ignore this chunk of code, and your version codes will be respected.
if (Boolean.valueOf(cdvBuildMultipleApks)) {
flavorDimensions "default"
productFlavors {
armeabi {
versionCode defaultConfig.versionCode*10 + 1
ndk {
abiFilters = ["armeabi"]
}
}
armv7 {
versionCode defaultConfig.versionCode*10 + 2
ndk {
abiFilters = ["armeabi-v7a"]
}
}
arm64 {
versionCode defaultConfig.versionCode*10 + 3
ndk {
abiFilters = ["arm64-v8a"]
}
}
x86 {
versionCode defaultConfig.versionCode*10 + 4
ndk {
abiFilters = ["x86"]
}
}
x86_64 {
versionCode defaultConfig.versionCode*10 + 5
ndk {
abiFilters = ["x86_64"]
}
}
}
} else if (Boolean.valueOf(cdvVersionCodeForceAbiDigit)) {
// This provides compatibility to the default logic for versionCode before cordova-android 5.2.0
defaultConfig {
versionCode defaultConfig.versionCode*10
}
}
compileOptions {
sourceCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_SOURCE_COMPATIBILITY)
targetCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
}
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
// If KOTLIN_JVM_TARGET is null, fallback to JAVA_TARGET_COMPATIBILITY,
// as they generally should be equal
cordovaConfig.KOTLIN_JVM_TARGET = cordovaConfig.KOTLIN_JVM_TARGET ?:
cordovaConfig.JAVA_TARGET_COMPATIBILITY
kotlinOptions {
jvmTarget = JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET)
}
}
if (cdvReleaseSigningPropertiesFile) {
signingConfigs {
release {
// These must be set or Gradle will complain (even if they are overridden).
keyAlias = ""
keyPassword = ""
storeFile = null
storePassword = ""
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
}
if (cdvDebugSigningPropertiesFile) {
addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
/*
* WARNING: Cordova Lib and platform scripts do management inside of this code here,
* if you are adding the dependencies manually, do so outside the comments, otherwise
* the Cordova tools will overwrite them
*/
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation "androidx.appcompat:appcompat:${cordovaConfig.ANDROIDX_APP_COMPAT_VERSION}"
implementation "androidx.core:core-splashscreen:${cordovaConfig.ANDROIDX_CORE_SPLASHSCREEN_VERSION}"
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${cordovaConfig.KOTLIN_VERSION}"
}
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${cordovaConfig.KOTLIN_VERSION}") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${cordovaConfig.KOTLIN_VERSION}") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "androidx.core:core:1.6.+"
implementation "androidx.webkit:webkit:1.4.0"
// SUB-PROJECT DEPENDENCIES END
}
def addSigningProps(propsFilePath, signingConfig) {
def propsFile = file(propsFilePath)
def props = new Properties()
propsFile.withReader { reader ->
props.load(reader)
}
def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
if (!storeFile.isAbsolute()) {
storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
}
if (!storeFile.exists()) {
throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
}
signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
signingConfig.storeFile = storeFile
signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
def storeType = props.get('storeType', props.get('key.store.type', ''))
if (!storeType) {
def filename = storeFile.getName().toLowerCase()
if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
storeType = 'pkcs12'
} else {
storeType = signingConfig.storeType // "jks"
}
}
signingConfig.storeType = storeType
}
for (def func : cdvPluginPostBuildExtras) {
func()
}
// This can be defined within build-extras.gradle as:
// ext.postBuildExtras = { … code here … }
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
if (cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
apply plugin: 'com.google.gms.google-services'
}
—
### ✅ Fix: Edit `scanner-qrscanner.gradle`
**Go to this file:**
platforms/android/cordova-plugin-qrscanner/scanner-qrscanner.gradle
**Find this line (likely near the top):**
compile 'com.journeyapps:zxing-android-embedded:3.3.0'
**Replace with:**
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
> `compile` is no longer valid in Gradle 7+, which Cordova now uses. It must be replaced with `implementation`.
—
### 🛠 Optional (But Safe) Enhancements
You may also want to verify if the `repositories` block exists, as sometimes Cordova plugins fail due to missing MavenCentral.
If missing, add this to the top or bottom of `scanner-qrscanner.gradle`:
repositories {
google()
mavenCentral()
}
—
### ✅ Then run:
cordova clean android
cordova build android
If this still fails, please paste the contents of `scanner-qrscanner.gradle` and I’ll fix it for you. Would you like that?
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
apply plugin: 'com.android.application'
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
apply plugin: 'kotlin-android'
if(!cdvHelpers.isVersionGreaterThanEqual(cordovaConfig.KOTLIN_VERSION, '1.8.0')) {
println "Kotlin version < 1.8.0 detected. Applying kotlin-android-extensions plugin."
apply plugin: 'kotlin-android-extensions'
}
}
buildscript {
apply from: '../CordovaLib/cordova.gradle'
// Checks if the kotlin version format is valid.
if(cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
if(!cdvHelpers.isVersionValid(cordovaConfig.KOTLIN_VERSION)) {
throw new GradleException("The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION}) does not appear to be a valid version.")
}
}
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${cordovaConfig.KOTLIN_VERSION}"
}
if(cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
// Checks if the kotlin version format is valid.
if(!cdvHelpers.isVersionValid(cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION)) {
throw new GradleException("The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version.")
}
// Create the Google Services classpath and set it.
String gradlePluginGoogleServicesClassPath = "com.google.gms:google-services:${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}"
println "Adding classpath: ${gradlePluginGoogleServicesClassPath}"
classpath gradlePluginGoogleServicesClassPath
}
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}
task wrapper(type: Wrapper) {
gradleVersion = cordovaConfig.GRADLE_VERSION
}
// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
apply from: '../CordovaLib/cordova.gradle'
// Sets the versionCode to the given value.
if (!project.hasProperty('cdvVersionCode')) {
cdvVersionCode = null
}
// Whether to build architecture-specific APKs.
if (!project.hasProperty('cdvBuildMultipleApks')) {
cdvBuildMultipleApks = null
}
// Whether to append a 0 "abi digit" to versionCode when only a single APK is build
if (!project.hasProperty('cdvVersionCodeForceAbiDigit')) {
cdvVersionCodeForceAbiDigit = null
}
// .properties files to use for release signing.
if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
cdvReleaseSigningPropertiesFile = null
}
// .properties files to use for debug signing.
if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
cdvDebugSigningPropertiesFile = null
}
// Set by build.js script.
if (!project.hasProperty('cdvBuildArch')) {
cdvBuildArch = null
}
// Plugin gradle extensions can append to this to have code run at the end.
cdvPluginPostBuildExtras = []
}
// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-qrscanner/scanner-qrscanner.gradle"
// PLUGIN GRADLE EXTENSIONS END
def hasBuildExtras1 = file('build-extras.gradle').exists()
if (hasBuildExtras1) {
apply from: 'build-extras.gradle'
}
def hasBuildExtras2 = file('../build-extras.gradle').exists()
if (hasBuildExtras2) {
apply from: '../build-extras.gradle'
}
// Apply updates that might come from build-extra.
privateHelpers.applyCordovaConfigCustomization()
// Set property defaults after extension .gradle files.
if (ext.cdvDebugSigningPropertiesFile == null && file('../debug-signing.properties').exists()) {
ext.cdvDebugSigningPropertiesFile = '../debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.properties').exists()) {
ext.cdvReleaseSigningPropertiesFile = '../release-signing.properties'
}
// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
def computeBuildTargetName(debugBuild) {
def ret = 'assemble'
if (cdvBuildMultipleApks && cdvBuildArch) {
def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
}
return ret + (debugBuild ? 'Debug' : 'Release')
}
// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
return computeBuildTargetName(true)
}
task cdvBuildRelease
cdvBuildRelease.dependsOn {
return computeBuildTargetName(false)
}
task cdvPrintProps {
doLast {
println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
println('cdvVersionCode=' + cdvVersionCode)
println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
println('cdvSdkVersion=' + cdvSdkVersion)
println('cdvMinSdkVersion=' + cdvMinSdkVersion)
println('cdvMaxSdkVersion=' + cdvMaxSdkVersion)
println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
println('cdvBuildArch=' + cdvBuildArch)
println('computedVersionCode=' + android.defaultConfig.versionCode)
println('cdvAndroidXAppCompatVersion=' + cdvAndroidXAppCompatVersion)
println('cdvAndroidXWebKitVersion=' + cdvAndroidXWebKitVersion)
android.productFlavors.each { flavor ->
println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
}
}
}
android {
namespace cordovaConfig.PACKAGE_NAMESPACE
buildFeatures {
buildConfig true
}
defaultConfig {
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId cordovaConfig.PACKAGE_NAMESPACE
minSdkVersion cordovaConfig.MIN_SDK_VERSION
if (cordovaConfig.MAX_SDK_VERSION != null) {
maxSdkVersion cordovaConfig.MAX_SDK_VERSION
}
targetSdkVersion cordovaConfig.SDK_VERSION
compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION
}
lintOptions {
abortOnError false
}
buildToolsVersion cordovaConfig.BUILD_TOOLS_VERSION
// This code exists for Crosswalk and other Native APIs.
// By default, we multiply the existing version code in the
// Android Manifest by 10 and add a number for each architecture.
// If you are not using Crosswalk or SQLite, you can
// ignore this chunk of code, and your version codes will be respected.
if (Boolean.valueOf(cdvBuildMultipleApks)) {
flavorDimensions "default"
productFlavors {
armeabi {
versionCode defaultConfig.versionCode*10 + 1
ndk {
abiFilters = ["armeabi"]
}
}
armv7 {
versionCode defaultConfig.versionCode*10 + 2
ndk {
abiFilters = ["armeabi-v7a"]
}
}
arm64 {
versionCode defaultConfig.versionCode*10 + 3
ndk {
abiFilters = ["arm64-v8a"]
}
}
x86 {
versionCode defaultConfig.versionCode*10 + 4
ndk {
abiFilters = ["x86"]
}
}
x86_64 {
versionCode defaultConfig.versionCode*10 + 5
ndk {
abiFilters = ["x86_64"]
}
}
}
} else if (Boolean.valueOf(cdvVersionCodeForceAbiDigit)) {
// This provides compatibility to the default logic for versionCode before cordova-android 5.2.0
defaultConfig {
versionCode defaultConfig.versionCode*10
}
}
compileOptions {
sourceCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_SOURCE_COMPATIBILITY)
targetCompatibility JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
}
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
// If KOTLIN_JVM_TARGET is null, fallback to JAVA_TARGET_COMPATIBILITY,
// as they generally should be equal
cordovaConfig.KOTLIN_JVM_TARGET = cordovaConfig.KOTLIN_JVM_TARGET ?:
cordovaConfig.JAVA_TARGET_COMPATIBILITY
kotlinOptions {
jvmTarget = JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET)
}
}
if (cdvReleaseSigningPropertiesFile) {
signingConfigs {
release {
// These must be set or Gradle will complain (even if they are overridden).
keyAlias = ""
keyPassword = ""
storeFile = null
storePassword = ""
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
}
if (cdvDebugSigningPropertiesFile) {
addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
/*
* WARNING: Cordova Lib and platform scripts do management inside of this code here,
* if you are adding the dependencies manually, do so outside the comments, otherwise
* the Cordova tools will overwrite them
*/
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation "androidx.appcompat:appcompat:${cordovaConfig.ANDROIDX_APP_COMPAT_VERSION}"
implementation "androidx.core:core-splashscreen:${cordovaConfig.ANDROIDX_CORE_SPLASHSCREEN_VERSION}"
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${cordovaConfig.KOTLIN_VERSION}"
}
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${cordovaConfig.KOTLIN_VERSION}") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${cordovaConfig.KOTLIN_VERSION}") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "androidx.core:core:1.6.+"
implementation "androidx.webkit:webkit:1.4.0"
// SUB-PROJECT DEPENDENCIES END
}
def addSigningProps(propsFilePath, signingConfig) {
def propsFile = file(propsFilePath)
def props = new Properties()
propsFile.withReader { reader ->
props.load(reader)
}
def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
if (!storeFile.isAbsolute()) {
storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
}
if (!storeFile.exists()) {
throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
}
signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
signingConfig.storeFile = storeFile
signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
def storeType = props.get('storeType', props.get('key.store.type', ''))
if (!storeType) {
def filename = storeFile.getName().toLowerCase()
if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
storeType = 'pkcs12'
} else {
storeType = signingConfig.storeType // "jks"
}
}
signingConfig.storeType = storeType
}
for (def func : cdvPluginPostBuildExtras) {
func()
}
// This can be defined within build-extras.gradle as:
// ext.postBuildExtras = { … code here … }
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
if (cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
apply plugin: 'com.google.gms.google-services'
}
add compileSDK verson
compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION
So the real issue is likely that `cordovaConfig.COMPILE_SDK_VERSION` is **undefined or not set properly**.
—
### ✅ Solution: Set `COMPILE_SDK_VERSION` manually
If Cordova doesn't auto-inject it, do this:
#### 🟩 Option 1: Hardcode it directly (quick fix)
In `platforms/android/build.gradle`, **replace**:
compileSdkVersion cordovaConfig.COMPILE_SDK_VERSION
**with**:
compileSdkVersion 35
(Also do the same for `targetSdkVersion` if needed.)
—
#### 🟩 Option 2: Set it in `gradle.properties`
Open this file:
platforms/android/gradle.properties
Add or edit:
cdvCompileSdkVersion=35
cdvTargetSdkVersion=35
cdvMinSdkVersion=21
Cordova will now inject these into the `cordovaConfig` object properly.
—
### ✅ Also fix the `scanner-qrscanner.gradle` file
Make sure it uses:
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
And not:
compile '...'
—
After all changes:
cordova clean android
cordova build android
Would you like me to give you a fixed version of `scanner-qrscanner.gradle` next?
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'CordovaLib/cordova.gradle'
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${cordovaConfig.KOTLIN_VERSION}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
cdvHelpers.verifyCordovaConfigForBuild()
}
allprojects {
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}
repositories repos
}
task clean(type: Delete) {
delete rootProject.buildDir
}
To fix the issue properly and update it for Gradle 7+, here’s a corrected and complete version of the `scanner-qrscanner.gradle` file:
—
### ✅ Updated `scanner-qrscanner.gradle` (Fixed for Gradle 7+)
// Plugin-level build.gradle for cordova-plugin-qrscanner
repositories {
google()
mavenCentral()
}
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
implementation 'com.google.zxing:core:3.3.0'
}
—
### ✅ Steps to apply fix:
1. Replace the contents of:
platforms/android/cordova-plugin-qrscanner/scanner-qrscanner.gradle
with the code above.
2. Clean and rebuild:
cordova clean android
cordova build android
—
Let me know if you want to upgrade `zxing` to a newer version or lock it for compatibility with Android SDK 35.
To recap:
—
## 🛠️ Problem
Your build error said:
> Could not find method compile() for arguments [...]
That refers specifically to this plugin Gradle file:
platforms/android/cordova-plugin-qrscanner/scanner-qrscanner.gradle
**That’s the file that needs fixing.**
—
## ✅ Solution
Here's the **correct content** for `scanner-qrscanner.gradle`:
### 🔧 `platforms/android/cordova-plugin-qrscanner/scanner-qrscanner.gradle`
repositories {
google()
mavenCentral()
}
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
implementation 'com.google.zxing:core:3.3.0'
}
—
## ✅ Then run:
cordova clean android
cordova build android
—
If you'd like, I can show you a command to patch this file automatically — would that help?
—
## ✅ Option 1: Hardcode `compileSdkVersion` (Quick & Reliable)
Open this file:
platforms/android/app/build.gradle
Find this block:
android {
defaultConfig {
...
}
}
Update it like this:
android {
compileSdkVersion 35
defaultConfig {
applicationId "com.example.app" // or your app ID
minSdkVersion 21
targetSdkVersion 35
versionCode 1
versionName "1.0"
}
...
}
> Replace `35` with the version you have installed (`android-35` in your case), and keep `minSdkVersion` and `targetSdkVersion` aligned.
—
## ✅ Option 2: Set in `gradle.properties` (Cordova-style fix)
Open this file:
platforms/android/gradle.properties
Add:
cdvCompileSdkVersion=35
cdvTargetSdkVersion=35
cdvMinSdkVersion=21
> This works only if your Cordova version/plugin is configured to consume these variables. If not, go with **Option 1**.
—
## 🔁 Then clean and rebuild:
cordova clean android
cordova build android
—
Let me know if you'd like a script to auto-apply this or want the `scanner-qrscanner.gradle` patch inline too.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :app:compileDebugJavaWithJavac FAILED
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:356: error: cannot find symbol
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(cordova.getActivity(), permission);
^
symbol: variable ActivityCompat
location: class QRScanner
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.
2 errors
[Incubating] Problems report is available at: file:///home/admin1/cordova/new/circusscanner/platforms/android/build/reports/problems/problems-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler output below.
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:356: error: cannot find symbol
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(cordova.getActivity(), permission);
^
symbol: variable ActivityCompat
location: class QRScanner
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.
2 errors
* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with –scan to get full insights.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '–warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1m 15s
32 actionable tasks: 32 executed
Command failed with exit code 1: /home/admin1/cordova/new/circusscanner/platforms/android/tools/gradlew cdvBuildDebug
—
## ✅ Solution: Update `QRScanner.java` to use AndroidX
You need to manually update the plugin file to replace the old import with the correct AndroidX equivalent.
### 🔧 Step-by-step fix:
1. Open this file:
platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java
2. Find this import (line 27 in your error):
import android.support.v4.app.ActivityCompat;
3. Replace it with:
import androidx.core.app.ActivityCompat;
4. Save the file.
—
## 🔁 Then Rebuild
cordova clean android
cordova build android
—
### 🔄 Optional: Make this change permanent
The `platforms/` folder is regenerated when you remove and re-add platforms or plugins. So:
– Either fork and fix the plugin on GitHub, then install it from your repo:
cordova plugin remove cordova-plugin-qrscanner
cordova plugin add https://github.com/YOUR_USERNAME/cordova-plugin-qrscanner.git
– Or use a post-install patching script (I can help write one) to auto-fix this after plugin install.
—
Do you want help automating this patch or forking the plugin with your fix?
—
### ✅ What happens if you downgrade to SDK 33?
– **`android.support.v4.app.ActivityCompat`** was supported up to **Android API 28** (but some support still works if using legacy support mode with SDK 33).
– Cordova Android **10.x+** uses **AndroidX** by default.
– So: if you **downgrade to SDK 33** and also **enable AndroidX backward compatibility**, it might work — but it's fragile.
—
### ⚠️ Potential Problems
– Google **requires targetSdkVersion 33 or above** for Play Store submissions (as of late 2023).
– Downgrading may introduce compatibility or security issues in the long term.
– Some Cordova plugins and libraries may still force AndroidX anyway.
—
### ✅ How to safely downgrade to API 33
#### 1. In `platforms/android/app/build.gradle`:
Replace:
compileSdkVersion 35
targetSdkVersion 35
With:
compileSdkVersion 33
targetSdkVersion 33
Keep `minSdkVersion` as is (e.g. 21).
—
#### 2. In `gradle.properties` (optional):
Set or update:
cdvCompileSdkVersion=33
cdvTargetSdkVersion=33
—
#### 3. Clean and rebuild:
cordova clean android
cordova build android
—
### ✅ Recommendation
If you're just trying to **quickly build and test locally**, downgrading to SDK 33 is fine.
But for **production or Play Store publishing**, it's better to:
– **Stick with SDK 34+**
– **Patch the plugin to use `androidx.core.app.ActivityCompat`**
—
Would you like a shell script that automatically patches the plugin to AndroidX when it's added?
The "compileSdkVersion" (34) should be greater than or equal to the the "targetSdkVersion" (35).
> Configure project :CordovaLib
The "compileSdkVersion" (34) should be greater than or equal to the the "targetSdkVersion" (35).
The "compileSdkVersion" (34) should be greater than or equal to the "targetSdkVersion" (35).
means your **`targetSdkVersion` is higher than `compileSdkVersion`**, which is **not allowed** in Android builds.
—
### ✅ Fix
You must make sure:
compileSdkVersion >= targetSdkVersion
—
### 🔧 Step-by-step Fix for Cordova
#### 1. Open this file:
platforms/android/app/build.gradle
Make sure these values are correct:
android {
compileSdkVersion 35
defaultConfig {
minSdkVersion 21
targetSdkVersion 35
}
}
> Set **both** `compileSdkVersion` and `targetSdkVersion` to **35** — since you confirmed you have `android-35` installed.
—
#### 2. Also update `gradle.properties` (optional but recommended):
In:
platforms/android/gradle.properties
Set:
cdvCompileSdkVersion=35
cdvTargetSdkVersion=35
—
#### 3. Clean and rebuild:
cordova clean android
cordova build android
—
Let me know if you'd like a script to apply all this automatically.
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:356: error: cannot find symbol
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(cordova.getActivity(), permission);
^
symbol: variable ActivityCompat
location: class QRScanner
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.
2 errors
[Incubating] Problems report is available at: file:///home/admin1/cordova/new/circusscanner/platforms/android/build/reports/problems/problems-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler output below.
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
/home/admin1/cordova/new/circusscanner/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:356: error: cannot find symbol
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(cordova.getActivity(), permission);
^
symbol: variable ActivityCompat
location: class QRScanner
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.
2 errors
* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with –scan to get full insights.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '–warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 6s
32 actionable tasks: 32 executed
import android.support.v4.app.ActivityCompat;
Which no longer exists in AndroidX projects (SDK 28+). You're using `compileSdkVersion 35`, which requires **AndroidX**.
—
## ✅ Fix: Patch `QRScanner.java` to use AndroidX
### Step 1: Edit the file
Open this file:
platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java
### Step 2: Replace the import
**Find:**
import android.support.v4.app.ActivityCompat;
**Replace with:**
import androidx.core.app.ActivityCompat;
—
### Step 3: Save and Rebuild
cordova clean android
cordova build android
—
## 🔁 Optional: Patch Automatically Every Time
Since Cordova regenerates `platforms/` folder, you may want to **auto-patch** it after `cordova prepare`.
Here’s a simple patch command:
sed -i 's|android.support.v4.app.ActivityCompat|androidx.core.app.ActivityCompat|' platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java
Or you can add this line to a `postinstall` script in `package.json`.
—
Would you like a permanent fork of the plugin or a shell script to handle this automatically?