当我在Android Studio 3.4.1中从Github克隆项目时,为什么build.gradle(项目)消失了?

时间:2019-07-01 03:17:04

标签: android-studio gradle github

我创建一个项目,build.gradle(项目)和build.gradle(模块)都在Android文件夹结构中正常列出,看起来像 Old Image 1 ,然后进行同步将项目迁移到Android Studio 3.4.1中的远程GitHub。

我从另一台PC的GitHub上克隆了项目,我发现build.gradle(项目)在另一台PC的Android文件夹结构中消失了,看起来像 New Image 1 ,但是我可以在Project文件夹结构中找到它,就像 New Image 2 。为什么?顺便说一句,克隆项目可以很好地工作。

似乎Github引起了问题,我该如何解决?谢谢!

旧图片1

enter image description here

新图片1

enter image description here

新图片2

enter image description here

至InsurgentPointerException:

这是项目级别的build.gradle

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

buildscript {

    ext.kotlin_version = '1.3.40'
    ext.anko_version = '0.10.8'

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // 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
}

再次发生InsurgentPointerException:

您可以通过

的克隆对其进行测试

https://github.com/mycwcgr/aa

您可以在以下位置下载Android Studio的项目源代码

https://www.dropbox.com/s/ko8stedl135ohnt/MyTest.zip?dl=0

1 个答案:

答案 0 :(得分:1)

所以似乎就像开发人员故意那样做。 IDK可能曾经有一些设置,但现在找不到了。此解决方案是一种(相当冗长的)解决方法。

  1. 关闭目标项目
  2. 重命名根项目文件夹
  3. 打开重命名的项目(可选)
  4. 在Android视图> Gradle脚本(可选)中看到build.gradleapp/build.gradle
  5. 关闭该项目(可选)
  6. 再次执行1-> 4,但重命名为旧项目名称。