簡體   English   中英

Android Studio項目同步失敗

[英]Android Studio project sync FAILED

我嘗試導入Udacity的android課程提供的項目,但是存在一些問題。 build.grade(app module)我將compile更改為implementation ,將testCompile更改為testImplementation 該項目成功同步,但是當我在模擬器上執行該項目時,出現了以下錯誤。

Could not find com.android.tools.build:aapt2:3.3.1-5013011.
Searched in the following locations:
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
Required by:
project :app

我認為無法找到構建所需的必需庫,但是我不知道該如何解決。 我在問題上進行了搜索,但找不到解決方案。 我的build.gradle文件是這樣的:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23

    defaultConfig {
        applicationId "com.example.android.miwok"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    api 'com.android.support:appcompat-v7:23.3.0'
    api 'com.android.support:support-v4:23.3.0'
    api 'com.android.support:design:23.3.0'
}

build.grade(項目)是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

檢查官方文檔

AAPT2(Android資產打包工具)是Android Studio和Android Gradle插件的構建工具。
Android Gradle Plugin 3.0.0和更高版本默認情況下啟用AAPT2。

使用要使用AAPT2的Android Studio 3.2 ,請確保build.gradle中具有google()依賴build.gradle

  buildscript {
      repositories {
          google() // here
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.2.0'
      }
  } allprojects {
      repositories {
          google() // and here
          jcenter()
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM