English 中文(简体)
科特林案卷的变化导致重新申报错误。
原标题:Kotlin file changes result in Redeclaration error

每一次对lin子案的改动都导致在建房时出现重复申报错误。 唯一的办法是清理项目,然后进行重建。 该项目没有其他文件,其名称与我正在编辑的档案相同。

我已尝试:

  • Renaming the class I have been working on
  • Upgrading and downgrading the version of kotlin, gradle and kotlin plugin in Android Studio
  • Using beta Android Studio
  • Reordering the plugins in my gradle file

The current build is using:

org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21
com.android.tools.build:gradle:3.2.0

Example code that will cause the error. If I build without the addedThisLine it works as its the first build. Then when I edit the file in anyway it will cause the error below.

package beagle.com

class ErrorFragment {

    val hello = "Hello"

    init {
        var goodbye = "goodbye"
        var addedThisLine = "When this line is added I get error"
    }
}

Irror

“Redeclaration

在我的项目中,每科特林档案中都出现这种情况,我前面的法典是最基本的文件。 你们可以看到,这错了班子的名称。

问题回答

just clean project and rebuild your project again

<<>strong>TL;DR: 您的名录名称与在<代码>上出现的名称相同。

值得一提的是: 澳门特区并不总是敏感的,可能会导致出现令人难忘的问题。


我认为,我找到了解决办法:Case deep uff

In my case I m using modules, let s just call the modules: moduleA, moduleB

<编码>制定。 页: 1 A , 模块B,但档案系统一级的名录为:moduleA/moduleB/

这似乎令人望而却步,不应奏效,但第一次运行总是奏效,然后,下一个项目在清理项目之前将失败。

I decided to keep things consistent and rename the directories as the settings.gradle lists them, even when in AndroidStudio they appear with the name listed in settings.gradle. This also helped to cleanup things because git has a configuration under .git/config which states to ignore the case sensitive stuff.

So, check the case of your directories vs. how they are listed in settings.gradle.

在用梯度重新命名和清洗之后,所有工作都与以前一样。

升级kotlingradle 后一版

Try to Run this may this will help

./gradlew clean
rm -rf ~/.gradle/caches/*

请在你的梯度上添加以下内容。 如果没有增加

apply plugin:  kotlin-android 
apply plugin:  kotlin-android-extensions 
apply plugin:  kotlin-kapt 

我有同样的问题,

./gradlew clean

这是我的解决办法。

这对我来说是有效的。

  1. Build > Clean Project
  2. Build > Rebuild Project
  3. Run

1. 清洁和重建

如果这不是为了阶级名称的冲突而工作!

Just Rename or change path of category ,因为您在same name of category !

如果是清洁项目Andbuil, 没有工作。 Try sync项目。 这为我工作。

in my case I have created same data class twice in same package was causing the error Redeclaration: Results . try to not create Kotlin class with same name in one package

在我的案件中,我使用了Kotlin 1.8和Delight 1.5.3。 我将 version光版缩为1.5.5,然后解决问题。

到2020年秋天,如果已经存在一个名称相同的类别,你就会发现这一澄清错误,因此,你们要么必须重新命名,要么转向不同的一揽子方案。

Kotlin compiler can fail in MacOS and Linux environments, when there is another Java file with the same name in the path. Renaming file can fix the issue as @sana says

关于喷气管问题的类似问题

明确这样做,改变法特林,再次尝试

buildscript {
 ext.kotlin_version =  1.9.0 
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...