-1

我正在尝试复制并构建一个不同的项目,以便我可以针对 Android Dev 教程中的练习问题更改一些内容。我已经继续并遵循了有关如何在此处复制项目的指南:https ://google-developer-training.github.io/android-developer-fundamentals-course-concepts-v2/appendix/appendix-utilities/附录-utilities.html

并在此处回答:在 Android Studio 中以新名称复制现有项目

但经过多次尝试,我都失败了。

这是我收到错误的地方,在我去同步 gradle 文件时,在 at 的回答的第 11 步,在我在其他地方更改了项目的名称后,它给了我这两个错误:

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.

org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.HelloToast3.tools.build:gradle:3.6.3.

这是我的项目build.gradle和我的模块应用程序build.gradle分别


buildscript {

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.HelloToast3.tools.build:gradle:3.6.3'


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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

apply plugin: 'com.HelloToast3.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.HelloToast3"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-HelloToast3-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

我是android studio的新手,也许这是一个简单的修复,但我还找不到解决方案。感谢所有的帮助。

4

1 回答 1

0

好的,我了解您的问题,但不完全了解。我想给你一个建议,当你将任何外部项目导入到 android studio 时,你应该间接地这样做。要解决任何类型的 gradle 或构建错误,您都可以做到,非常简单。

  1. 使用android studio创建一个空项目并关闭它
  2. 将项目中的所有类和 res 文件夹复制到您想要将其导入到 android studio 的新创建的空项目中
  3. 现在导入新项目而不是旧项目
于 2020-06-08T04:59:01.547 回答