我.gitignore的Android Studio项目应该包含哪些文件?
我已经看到几个例子都包括.iml但IntelliJ文档说.iml必须包含在你的源代码管理中.
我正在尝试编写程序,但是我收到了这个编译错误:
Main.java:1: error: class WeatherArray is public, should be declared in a file named WeatherArray.java
public class WeatherArray {
^
1 error
Run Code Online (Sandbox Code Playgroud)
我检查了我的文件名,我的公共类与我的.java文件相同.
我怎样才能解决这个问题?
这是我的代码:
public class WeatherArray {
public static void main(String[] args) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud) Android Studio 不断创建生成的类,即使它们已经存在。
我猜这个问题与 NavigationArgs 有关,但它总是会出现一些重复错误。
现在解决我的问题的唯一方法是每次运行应用程序之前清理整个项目。
有谁知道如何解决这个问题,我怎么知道是哪个实现导致了这个错误?
摇篮项目
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0-beta01"
classpath ('com.google.firebase:firebase-plugins:1.1.0') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
摇篮模块
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' …Run Code Online (Sandbox Code Playgroud) 当我在 Android Studio 中重新运行我的应用程序时,我收到了一个随机错误列表,包括“运行应用程序”和“应用更改”。我必须清理和重建,然后它才能工作。像这样的错误:
Program type already present: androidx.transition.R
Duplicate resources
error: class BuildConfig is public, should be declared in a file named BuildConfig.java
Program type already present: androidx.recyclerview.R$drawable
Program type already present: androidx.lifecycle.extensions.R$style
Run Code Online (Sandbox Code Playgroud)
类型loadImageToStorage$2被定义多次:
为什么我不断收到这些消息?它极大地减慢了我的工作。
它似乎主要与重复资源有关,但是当我执行“构建”然后运行它时,它总是会清除。
我已经完全卸载了Android Studio,并重新安装,我仍然有同样的问题。在 mac 上运行。
非常感谢。
我将我的项目迁移到 Androidx,每次运行我的项目时,我都会收到这个错误,提示类 BuildConfig 是公共的,应该在名为 BuildConfig.java 的文件中声明。我知道我的原因是每次构建我的项目时,我的 java BuildConfig 类都会不断重复。这给了它一个名称,如 BuildConfig1、BuildConfig2 等。我经常不得不删除它并重新运行我的项目以编译这真的很烦人有没有人知道这个的原因,也许是一个修复?这是我的 BuildConfig 类
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.examp.smartshop";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}
Run Code Online (Sandbox Code Playgroud)