java - 尝试复制和重建项目时出现 Android Studio 错误

标签 java android android-studio gradle

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

和 a.t. 的答案在这里:Copy existing project with a new name in Android Studio

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

这是我收到错误的地方,在我去同步 gradle 文件时,在 at.t. 的回答的第 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的新手,也许这是一个简单的修复,但我还找不到解决方案。感谢所有的帮助。

最佳答案

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

  • 使用android studio创建一个空项目并关闭它
  • 将项目中的所有类和 res 文件夹复制到您要导入到 android studio 的新创建的空项目
  • 现在导入新项目而不是旧项目
  • 关于java - 尝试复制和重建项目时出现 Android Studio 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62253130/

    相关文章:

    java - Spring 和@Value 注解

    Android - 使用 AlertDialog 时上下文为空

    android - 如何确定 Google Play 服务的版本?

    Android ndk 错误 asm types.h 未找到

    java - 如何在java中不向server.log抛出异常

    java - JDialog无法转换为框架

    java - 如果 block 变量定义给出错误,则非大括号

    android - 无法播放文件中录制的原始 PCM

    android - 单击 flutter 中的底部按钮时在半屏中显示选项卡

    android - 错误 :duplicate files during packaging of APK