简体   繁体   English

无法在 Android Studio 中执行复制粘贴

[英]Can Not Perform Copy-Paste in Android Studio

I have faced two main problems in Android Studio.我在 Android Studio 中遇到了两个主要问题。 First of all I can not perform copy-paste and cut-paste ( ctrl + c - ctrl + v - ctrl + x ) abilities in some classes.首先,我无法在某些课程中执行复制粘贴剪切粘贴ctrl + c - ctrl + v - ctrl + x )功能。 To fix that problem, I click "invalide caches/restarts", but it breaks down again immediately.为了解决这个问题,我点击了“invalide caches/restarts”,但它立即再次崩溃。

Second problem is (I think it is related to the first problem) compiler does not recognize already defined methods and attributes.第二个问题是(我认为它与第一个问题有关)编译器无法识别已经定义的方法和属性。 Auto suggestion etc. does not work.自动建议等不起作用。

The steps I've taken to try to fix the problem are;我为尝试解决问题而采取的步骤是;

  1. File -> invalide caches/restarts,文件 -> 无效缓存/重启,
  2. File -> Power Save Mode -> Disable,文件 -> 省电模式 -> 禁用,
  3. Close all opened tabs and fresh restart,关闭所有打开的标签并重新启动,
  4. File -> Sync Project with Gradle Files,文件 -> 将项目与 Gradle 文件同步,
  5. File -> Sync with File System,文件 -> 与文件系统同步,
  6. Delete JDK and reinstall,删除JDK并重新安装,
  7. Delete Android Studio and reinstall,删除Android Studio并重新安装,
  8. Delete already downloaded SDK files and ".Android" folder,删除已下载的 SDK 文件和“.Android”文件夹,
  9. Disable and delete all plugins.禁用并删除所有插件。
  10. Checked copy-paste keymap in File -> Settings -> Keymap在文件 -> 设置 -> 键盘映射中检查复制粘贴键盘映射
  11. Pulled the project from bitbucket to different 2 computers将项目从 bitbucket 拉到不同的 2 台计算机
  12. Created new project, copy whole project classes with NotePad++ to new Project创建新项目,使用 NotePad++ 将整个项目类复制到新项目
  13. Try to convert all Java codes to Kotlin, cannot convert尝试将所有Java代码转换为Kotlin,无法转换

Here is my system specifications;这是我的系统规格; Windows 10 Home Single Language (TR), version 1909. 16 GB ram. Windows 10 家庭单语言 (TR),版本 1909。16 GB 内存。 Android Studio 3.5.3 and Gradle Version 3.5.3 Android Studio 3.5.3 和 Gradle 版本 3.5.3

I have read all post about the same problem but there is no luck (The posts are only about MAC and Linux platform).我已经阅读了所有关于同一问题的帖子,但没有运气(这些帖子仅关于 MAC 和 Linux 平台)。

UPDATE 1.0 -> I have discovered that some classes cannot do the operations described above, but some classes can. UPDATE 1.0 ->我发现有些类不能执行上述操作,但有些类可以。

I realized that, There are no icons for classes that cannot do the operations I have described above.我意识到,不能执行我上面描述的操作的类没有图标。 (Sometimes magically appears "J" icons and when I clicked another class, this J icon disappears immediately.) I think gradle or file system of Android Studio does not recognize these files as classes. (有时会神奇地出现“J”图标,当我点击另一个类时,这个 J 图标会立即消失。)我认为 Android Studio 的 gradle 或文件系统不会将这些文件识别为类。

UPDATE 2.0 -> I have noticed that when I clicked the Structure section of DuoFragment (Which has 500+ lines codes and one of the uncompiled class) cannot load anything.更新 2.0 ->我注意到当我单击 DuoFragment 的 Structure 部分(其中有 500 多行代码和未编译的类之一)时,无法加载任何内容。 Is DuoFragment size is bigger to process? DuoFragment 的尺寸是否更大以进行处理?

Also when I checked the Build section, some processes cannot run (I do not know if this is normal or not);另外在查看Build部分时,有些进程无法运行(不知道是否正常);

  • Task :app:compileDebugAidl NO-SOURCE,任务 :app:compileDebugAidl NO-SOURCE,
  • Task :app:compileDebugRenderscript NO-SOURCE,任务 :app:compileDebugRenderscript NO-SOURCE,
  • Task :app:processDebugJavaRes NO-SOURCE任务 :app:processDebugJavaRes NO-SOURCE

UPDATE 3.0 ->更新 3.0 ->

Here are my Gradle files.这是我的 Gradle 文件。 Project Level Gradle file :项目级 Gradle 文件:

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

buildscript {
    repositories {
        google()
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'


        // 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
}

App level Gradle file.应用级 Gradle 文件。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.lotusif.dump2"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.core:core:1.1.0'

    // material widgets
    implementation 'com.google.android.material:material:1.2.0-alpha03'

    // progress bar with text 
    implementation "com.github.skydoves:progressview:1.0.3"

    // sequence progress
   implementation 'com.github.transferwise:sequence-layout:1.0.11'

    // flash bar
   implementation 'com.andrognito.flashbar:flashbar:1.0.2'

    // toggle - switch button
   implementation 'com.github.GwonHyeok:StickySwitch:0.0.15'

    // Custom Toast message
    implementation 'com.github.GrenderG:Toasty:1.4.2'

    // liquid effect bar
    implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'

    // bubble tab bar
    implementation 'com.fxn769:bubbletabbar:1.0.3'

    //glide image library
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

    // scaling layout
    implementation 'com.github.iammert:ScalingLayout:1.2.1'

    // lottie animation
    implementation 'com.airbnb.android:lottie:3.3.1'

    //Gson
    implementation 'com.google.code.gson:gson:2.8.6'

    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    implementation 'com.daimajia.easing:library:2.1@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'

    //retrofit
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'

}

没有建议 键盘映射 安卓版 如果我不添加额外的代码,Gradle 同步成功

UPDATE 1.0 Images更新 1.0 图像

没有图标或只有“J”图标的类不能进行操作

当我点击/打开另一个课程时,“J”图标消失了

UPDATE 2.0 Images更新 2.0 图像

某些过程无法在构建部分完成 无法加载 DuoFragment 结构 DuoFragment 代码总结

UPDATE --> There is a bug in Kotlin libraries with Windows 10 Single Language Turkish .更新--> Windows 10 单语言土耳其语的Kotlin 库中存在一个错误。 (Maybe some of other Single Language Windows distributions have same issue, I haven't known yet.) Kotlin's some libraries cannot work on Turkish operating system. (也许其他一些单语言 Windows 发行版也有同样的问题,我还不知道。)Kotlin 的一些库不能在土耳其语操作系统上运行。 I solved this problem with installing Windows 10 Pro English .我通过安装Windows 10 Pro English解决了这个问题。

Other developers who use Windows 10 Single Language Turkish faces same problem with different angles.其他使用 Windows 10 单语言土耳其语的开发人员在不同角度面临同样的问题。 ( Example1 and Example2 ) 例1例2

OLD ANSWER旧答案

TL;DR -> Problem is about third party libraries that are written with Kotlin . TL;DR -> 问题是关于用Kotlin编写的第三方库。 I have converted my Java project to Kotlin and all problematic third party libraries work well.我已将我的 Java 项目转换为 Kotlin,并且所有有问题的第三方库都运行良好。 Problem is about Java - Kotlin conflict .问题是关于 Java-Kotlin 冲突

I would like to share how I solved the problem for those who will face such problems later.我想分享一下我是如何解决问题的,供以后遇到此类问题的人使用。

I did all the steps I mentioned above one by one but I could not find any solution and I decided to examine my third party libraries.我一一执行了上面提到的所有步骤,但找不到任何解决方案,因此我决定检查我的第三方库。

First of all, I disabled all third party libraries and looked at the status of my classes that did not recognize already defined methods and attributes.首先,我禁用了所有第三方库,并查看了无法识别已定义方法和属性的类的状态。 After disabling third party libraries and making Rebuild Project and Sync Gradle, the Auto Suggestion feature of those corrupted classes started working again.Then, uncovering which third-party libraries were problematic, I activated those third-party libraries one by one.在禁用第三方库并进行 Rebuild Project 和 Sync Gradle 后,那些损坏的类的自动建议功能再次开始工作。 然后,发现哪些第三方库有问题,我将这些第三方库一一激活。 I found which third party libraries broke my project.我发现哪些第三方库破坏了我的项目。

There were 4 third party libraries that broke my project : StickySwitch , ProgressView , SequenceLayout and Flashbar .有 4 个第三方库破坏了我的项目: StickySwitchProgressViewSequenceLayoutFlashbar When I removed those libraries, everything worked right.当我删除这些库时,一切正常。 After removed the libraries, my Gradle file was as below.删除库后,我的 Gradle 文件如下。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.lotusif.dump2"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.core:core:1.1.0'

    // material widgets
    implementation 'com.google.android.material:material:1.2.0-alpha03'

    // progress bar with text BUGGY!
    // implementation "com.github.skydoves:progressview:1.0.3"

    // sequence progress BUGGY !
    // implementation 'com.github.transferwise:sequence-layout:1.0.11'

    // flash bar BUGGY !
    // implementation 'com.andrognito.flashbar:flashbar:1.0.2'

    // toggle - switch button BUGGY !
    // implementation 'com.github.GwonHyeok:StickySwitch:0.0.15'

    // Custom Toast message
       implementation 'com.github.GrenderG:Toasty:1.4.2'

    // liquid effect bar
       implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'


    // bubble tab bar
       implementation 'com.fxn769:bubbletabbar:1.0.3'

    // android chart library
       implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

    //glide image library
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

    // scaling layout
    implementation 'com.github.iammert:ScalingLayout:1.2.1'

    // lottie animation
    implementation 'com.airbnb.android:lottie:3.3.1'

    //Gson
    implementation 'com.google.code.gson:gson:2.8.6'

    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    implementation 'com.daimajia.easing:library:2.1@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'

    //retrofit
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
}

So, what was the common feature of those libraries that corrupt my project?那么,那些破坏我的项目的库的共同特征是什么? My project was written with Java but that libraries were written with Kotlin .我的项目是用Java编写的,但该库是用Kotlin编写的。 One second, cannot I use Kotlin libraries in my Java project?一秒钟,我不能在我的 Java 项目中使用 Kotlin 库吗? Yes, I can .是的,我可以 I have to add android.useAndroidX=true and android.enableJetifier=true in my gradle.properties , that is it.我必须在我的gradle.properties 中添加android.useAndroidX=trueandroid.enableJetifier=true ,就是这样。 But what if I have already added those lines in my gradle.properties and it has not worked?但是如果我已经在我的gradle.properties 中添加了这些行并且它没有工作怎么办?

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

I have not understood why kotlin libraries cannot work with my Java project.我不明白为什么 kotlin 库不能用于我的 Java 项目。 As you can see in my Gradle file , I am using apply plugin: 'kotlin-android' and apply plugin: 'kotlin-android-extensions' for Kotlin support.正如你在我的Gradle 文件中看到的,我使用apply plugin: 'kotlin-android'apply plugin: 'kotlin-android-extensions'来支持 Kotlin。

How I have rescued my project?我是如何拯救我的项目的? There were 2 available options as I knew.据我所知,有 2 个可用选项。 While first method was that to removed those 4 third party libraries and could not use them, second one that to convert all Java classes to Kotlin classes (I tried it before but it did not work until disabled all third party libraries).第一种方法是删除这 4 个第三方库而无法使用它们,第二种方法是将所有 Java 类转换为 Kotlin 类(我之前尝试过,但它在禁用所有第三方库后才起作用)。 I chose to convert all Java classes to Kotlin classes.我选择将所有 Java 类转换为 Kotlin 类。 Thus, I was able to use 4 third party libraries which were mentioned above.因此,我能够使用上面提到的 4 个第三方库。

It took me 30 days to solve this problem.我花了 30 天的时间来解决这个问题。 Now, I am working on Kotlin language.现在,我正在研究 Kotlin 语言。 As a result, my project is running without any problem.结果,我的项目运行没有任何问题。

I have faced two main problems in Android Studio.我在Android Studio中遇到了两个主要问题。 First of all I can not perform copy-paste and cut-paste ( ctrl + c - ctrl + v - ctrl + x ) abilities in some classes.首先,在某些类中,我无法执行复制粘贴剪切粘贴ctrl + c - ctrl + v - ctrl + x )功能。 To fix that problem, I click "invalide caches/restarts", but it breaks down again immediately.要解决该问题,我单击“无效的缓存/重新启动”,但它立即再次崩溃。

Second problem is (I think it is related to the first problem) compiler does not recognize already defined methods and attributes.第二个问题是(我认为与第一个问题有关)编译器无法识别已经定义的方法和属性。 Auto suggestion etc. does not work.自动建议等不起作用。

The steps I've taken to try to fix the problem are;我已尝试解决此问题的步骤是:

  1. File -> invalide caches/restarts,文件->无效缓存/重启,
  2. File -> Power Save Mode -> Disable,文件->省电模式->禁用,
  3. Close all opened tabs and fresh restart,关闭所有打开的标签页,然后重新启动,
  4. File -> Sync Project with Gradle Files,文件->使用Gradle文件同步项目,
  5. File -> Sync with File System,文件->与文件系统同步,
  6. Delete JDK and reinstall,删除JDK并重新安装,
  7. Delete Android Studio and reinstall,删除Android Studio并重新安装,
  8. Delete already downloaded SDK files and ".Android" folder,删除已经下载的SDK文件和“ .Android”文件夹,
  9. Disable and delete all plugins.禁用并删除所有插件。
  10. Checked copy-paste keymap in File -> Settings -> Keymap在文件->设置->键盘映射中检查复制粘贴键盘映射
  11. Pulled the project from bitbucket to different 2 computers将项目从bitbucket拉到不同的2台计算机
  12. Created new project, copy whole project classes with NotePad++ to new Project创建新项目,将带有NotePad ++的整个项目类复制到新项目中
  13. Try to convert all Java codes to Kotlin, cannot convert尝试将所有Java代码转换为Kotlin,无法转换

Here is my system specifications;这是我的系统规格; Windows 10 Home Single Language (TR), version 1909. 16 GB ram. Windows 10家庭单一语言(TR)版本1909.RAM 16 GB。 Android Studio 3.5.3 and Gradle Version 3.5.3 Android Studio 3.5.3和Gradle版本3.5.3

I have read all post about the same problem but there is no luck (The posts are only about MAC and Linux platform).我已经阅读了有关同一问题的所有文章,但没有运气(这些文章仅关于MAC和Linux平台)。

UPDATE 1.0 -> I have discovered that some classes cannot do the operations described above, but some classes can. UPDATE 1.0->我发现有些类不能执行上述操作,但有些类可以。

I realized that, There are no icons for classes that cannot do the operations I have described above.我意识到,没有类的图标无法执行上述操作。 (Sometimes magically appears "J" icons and when I clicked another class, this J icon disappears immediately.) I think gradle or file system of Android Studio does not recognize these files as classes. (有时会神奇地显示“ J”图标,当我单击另一个类时,该J图标会立即消失。)我认为Android Studio的gradle或文件系统无法将这些文件识别为类。

UPDATE 2.0 -> I have noticed that when I clicked the Structure section of DuoFragment (Which has 500+ lines codes and one of the uncompiled class) cannot load anything. UPDATE 2.0->我注意到,当我单击DuoFragment的Structure部分时(其中有500多个行代码,并且是未编译的类之一)无法加载任何内容。 Is DuoFragment size is bigger to process? DuoFragment的尺寸更大吗?

Also when I checked the Build section, some processes cannot run (I do not know if this is normal or not);另外,当我检查“构建”部分时,某些进程无法运行(我不知道这是否正常)。

  • Task :app:compileDebugAidl NO-SOURCE,任务:app:compileDebugAidl NO-SOURCE,
  • Task :app:compileDebugRenderscript NO-SOURCE,任务:app:compileDebugRenderscript NO-SOURCE,
  • Task :app:processDebugJavaRes NO-SOURCE任务:app:processDebugJavaRes NO-SOURCE

UPDATE 3.0 ->更新3.0->

Here are my Gradle files.这是我的Gradle文件。 Project Level Gradle file :项目级Gradle文件:

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

buildscript {
    repositories {
        google()
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'


        // 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
}

App level Gradle file.应用程序级别的Gradle文件。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.lotusif.dump2"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.core:core:1.1.0'

    // material widgets
    implementation 'com.google.android.material:material:1.2.0-alpha03'

    // progress bar with text 
    implementation "com.github.skydoves:progressview:1.0.3"

    // sequence progress
   implementation 'com.github.transferwise:sequence-layout:1.0.11'

    // flash bar
   implementation 'com.andrognito.flashbar:flashbar:1.0.2'

    // toggle - switch button
   implementation 'com.github.GwonHyeok:StickySwitch:0.0.15'

    // Custom Toast message
    implementation 'com.github.GrenderG:Toasty:1.4.2'

    // liquid effect bar
    implementation 'com.mikhaellopez:circularfillableloaders:1.3.2'

    // bubble tab bar
    implementation 'com.fxn769:bubbletabbar:1.0.3'

    //glide image library
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

    // scaling layout
    implementation 'com.github.iammert:ScalingLayout:1.2.1'

    // lottie animation
    implementation 'com.airbnb.android:lottie:3.3.1'

    //Gson
    implementation 'com.google.code.gson:gson:2.8.6'

    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    implementation 'com.daimajia.easing:library:2.1@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'

    //retrofit
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'

}

没有建议 按键图 Android版 如果我不添加其他代码,则Gradle同步成功

UPDATE 1.0 Images UPDATE 1.0图片

没有图标或仅具有“ J”图标的类无法进行操作

当我单击/打开另一个班级时,“ J”图标消失了

UPDATE 2.0 Images UPDATE 2.0图片

在“构建”部分中无法完成某些过程 无法加载DuoFragment结构 DuoFragment代码摘要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM