我在我的Android Studio/ionic build的Gradle build中遇到了这个问题(使用angular)|离子电容器运行Android

njthzxwz  于 2023-09-28  发布在  Ionic
关注(0)|答案(1)|浏览(186)

基本上我使用离子/gradle和android工作室来模拟,但它一直在Vscode终端上给出这个问题。我想说的是,我正在使用Angular。
终端:离子电容器运行android

capacitor.cmd run android --target Pixel_2_API_30
[capacitor] √ Copying web assets from www to android\app\src\main\assets\public in 2.66s
[capacitor] √ Creating capacitor.config.json in android\app\src\main\assets in 1.94ms
[capacitor] [info] Inlining sourcemaps
[capacitor] √ copy android in 3.01s
[capacitor] √ Updating Android plugins in 15.82ms
[capacitor] [info] Found 4 Capacitor plugins for android:
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor]        @capacitor/[email protected]
[capacitor] √ update android in 134.47ms
[capacitor] × Running Gradle build - failed!
[capacitor] [error] 
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]
[capacitor]         * Where:
[capacitor]         Build file 'C:\Users\fjmor\ionic\lista\android\build.gradle' line: 2
[capacitor]
[capacitor]         * What went wrong:
[capacitor]         Could not compile build file 'C:\Users\fjmor\ionic\lista\android\build.gradle'.
[capacitor]         > startup failed:
[capacitor]         build file 'C:\Users\fjmor\ionic\lista\android\build.gradle': 2: Unexpected input: '{' @ line 2, column 13.
[capacitor]         allprojects {
[capacitor]         ^
[capacitor]
[capacitor]         1 error
[capacitor]
[capacitor]
[capacitor]         * Try:
[capacitor]         > Run with --stacktrace option to get the stack trace.
[capacitor]         > Run with --info or --debug option to get more log output.
[capacitor]         > Run with --scan to get full insights.
[capacitor]
[capacitor]         * Get more help at https://help.gradle.org
[capacitor]
[capacitor]         BUILD FAILED in 1s
[capacitor]
[ERROR] An error occurred while running subprocess capacitor.

        capacitor.cmd run android --target Pixel_2_API_30 exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

h退出代码1。

Re-running this command with the --verbose flag may provide more information.

我的build.gradle的内容:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        classpath 'com.google.gms:google-services:4.3.15'

        // 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
}

`
我已经尝试安装不同版本的Gradle和Java,但它什么也没做。有人知道我该怎么解决这个问题吗?

yhqotfr8

yhqotfr81#

输出指示build.gradle文件中存在语法错误。我建议查看第2行,看看它是否确实缺少一个括号。如果您觉得正确,请尝试在终端窗口的项目目录中运行./gradlew clean,或者在Android Studio中转到Project > Clean Build Folder。然后尝试重建项目。

相关问题