Problem runnnin ionic app on Android Studio 2024

auto_awesome

Traducir del: inglés

978 / 5.000

Resultados de traducción

Resultado de traducción

Hi guys, I made a small app using ionic v7 capacitor 6, it’s a counter, everything works fine when running it in the web version and when compiling, but when running the open android command when opening Android Studio I get this error: Multiple build operations failed. could not initialize class com.android.sdklib.repository.AndroidSdkHandler Could not initialize class com.android.sdklib.repository.AndroidSdk Handler Could not initialize class com.android.sdklib.repository.AndroidSdkHandler Could not initialize class com.android.sdklib.repository.AndroidSdkHandler Could not initialize class com.android.sdklib.repository.AndroidSdkHandler javax/xml/bind/annotation/XmlSchema javax.xml.bind.annotation.XmlSchema

can someone guide me how to solve this error

What does your build.gradle file look like?

This SO post points to an outdated build tool version.

You can also try following the troubleshooting steps here - Troubleshooting Android Issues | Capacitor Documentation.

Hello, I’m going to review the solutions you indicated. I will also put the content of the build.gradle file here. There are two, one in the root of the project that has this:
buildscript {

repositories {
    google()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:8.2.1'
    classpath 'com.google.gms:google-services:4.4.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

apply from: “variables.gradle”

allprojects {
repositories {
google()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
The other one that is inside the app that has this:
apply plugin: ‘com.android.application’

android {

buildToolsVersion '35.0.0'
namespace "io.ionic.starter"

compileSdk 35
defaultConfig {
applicationId “io.ionic.starter”
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName “1.0”
testInstrumentationRunner “androidx.test.runner.AndroidJUnitRunner”
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: tools/aapt/AaptAssets.cpp - platform/frameworks/base - Git at Google
ignoreAssetsPattern ‘!.svn:!.git:!.ds_store:!.scc:.:!CVS:!thumbs.db:!picasa.ini:!*~’
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}

repositories {
flatDir{
dirs ‘…/capacitor-cordova-android-plugins/src/main/libs’, ‘libs’
}
}

dependencies {
implementation fileTree(include: [‘*.jar’], dir: ‘libs’)
implementation “androidx.appcompat:appcompat:$androidxAppCompatVersion”
implementation “androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion”
implementation “androidx.core:core-splashscreen:$coreSplashScreenVersion”
implementation project(‘:capacitor-android’)
testImplementation “junit:junit:$junitVersion”
androidTestImplementation “androidx.test.ext:junit:$androidxJunitVersion”
androidTestImplementation “androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion”
implementation project(‘:capacitor-cordova-android-plugins’)

}

apply from: ‘capacitor.build.gradle’

try {
def servicesJSON = file(‘google-services.json’)
if (servicesJSON.text) {
apply plugin: ‘com.google.gms.google-services’
}
} catch(Exception e) {
logger.info(“google-services.json not found, google-services plugin not applied. Push Notifications won’t work”)
}

Why are you using compileSdk 35 and build tools 35?
Those are for Android 15, which is still in beta stage.

I think you need Android Studio beta to work with those.

Greetings, you are right, I was reviewing the official documentation and the minimum SDK target for Capacitor 6 is 34. I think that is the problem. I will review that point. Thank you very much.