无法在Android Studio中执行复制粘贴 [英] Can Not Perform Copy-Paste in Android Studio

查看:1761
本文介绍了无法在Android Studio中执行复制粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android Studio中遇到了两个主要问题.首先,我无法执行复制粘贴剪切粘贴( ctrl + c - ctrl + v - ctrl + x )功能.要解决该问题,我单击无效的缓存/重新启动",但它立即再次崩溃.

I have faced two main problems in Android Studio. First of all I can not perform copy-paste and cut-paste (ctrl+c - ctrl+v - ctrl+x) abilities in some classes. 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. 文件->使高速缓存无效/重新启动,
  2. 文件->省电模式->禁用,
  3. 关闭所有打开的标签页并重新启动,
  4. 文件->使用Gradle文件同步项目,
  5. 文件->与文件系统同步,
  6. 删除JDK并重新安装,
  7. 删除Android Studio并重新安装,
  8. 删除已经下载的SDK文件和".Android"文件夹,
  9. 禁用并删除所有插件.
  10. 在文件"->设置"->键盘映射"中检查复制粘贴键盘映射
  11. 将项目从bitbucket中拉到不同的2台计算机上
  12. 创建了新项目,使用NotePad ++将整个项目类复制到 新项目
  13. 尝试将所有Java代码转换为Kotlin,无法转换
  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,
  5. File -> Sync with File System,
  6. Delete JDK and reinstall,
  7. Delete Android Studio and reinstall,
  8. Delete already downloaded SDK files and ".Android" folder,
  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
  12. Created new project, copy whole project classes with NotePad++ to new Project
  13. Try to convert all Java codes to Kotlin, cannot convert

这是我的系统规格; Windows 10家庭单一语言(TR)版本1909.RAM 16 GB. Android Studio 3.5.3和Gradle版本3.5.3

Here is my system specifications; Windows 10 Home Single Language (TR), version 1909. 16 GB ram. Android Studio 3.5.3 and Gradle Version 3.5.3

我已经阅读了有关同一问题的所有文章,但没有运气(这些文章仅关于MAC和Linux平台).

I have read all post about the same problem but there is no luck (The posts are only about MAC and Linux platform).

UPDATE 1.0-> 我发现有些类不能执行上述操作,但是有些类可以.

UPDATE 1.0 -> I have discovered that some classes cannot do the operations described above, but some classes can.

我意识到,对于无法执行上述操作的类,没有图标. (有时会神奇地显示"J"图标,当我单击另一个类时,该J图标会立即消失.)我认为Android Studio的gradle或文件系统无法将这些文件识别为类.

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.

UPDATE 2.0-> 我注意到当我单击DuoFragment的Structure部分时(其中有500多个行代码,并且是未编译的类之一)无法加载任何内容. DuoFragment的尺寸更大吗?

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. Is DuoFragment size is bigger to process?

另外,当我检查构建"部分时,某些进程无法运行(我不知道这是否正常);

Also when I checked the Build section, some processes cannot run (I do not know if this is normal or not);

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

UPDATE 3.0->

这是我的Gradle文件. 项目级Gradle文件:

Here are my Gradle files. Project Level Gradle file :

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

应用级Gradle文件.

App level Gradle file.

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'

}

更新1.0图片

更新2.0图片

推荐答案

更新-> 在使用 Windows 10单一语言土耳其语的Kotlin库中存在一个错误. (也许其他一些Single Language Windows发行版也有同样的问题,我还不知道.)Kotlin的某些库无法在土耳其语操作系统上工作.我通过安装 Windows 10专业版英语解决了这个问题.

UPDATE --> There is a bug in Kotlin libraries with Windows 10 Single Language Turkish. (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. I solved this problem with installing Windows 10 Pro English.

使用Windows 10单一语言土耳其语的其他开发人员在不同角度都面临相同的问题. ( Example1 Example2 )

Other developers who use Windows 10 Single Language Turkish faces same problem with different angles. (Example1 and Example2)

旧答案

TL; DR ->问题与使用 Kotlin 编写的第三方库有关.我已经将Java项目转换为Kotlin,并且所有有问题的第三方库都运行良好. 问题与Java – Kotlin冲突有关.

TL;DR -> Problem is about third party libraries that are written with Kotlin. I have converted my Java project to Kotlin and all problematic third party libraries work well. Problem is about Java - Kotlin conflict.

我想与那些以后会遇到此类问题的人分享我如何解决该问题.

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.

首先,我禁用了所有第三方库,并查看了无法识别已经定义的方法和属性的类的状态.禁用第三方库并创建Rebuild Project和Sync Gradle之后,这些损坏的类的自动建议功能再次开始工作.然后,发现哪些第三方库有问题,我一步一步地激活了这些第三方库.我发现哪个第三方图书馆破坏了我的项目.

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. I found which third party libraries broke my project.

有4个第三方库破坏了我的项目: StickySwitch SequenceLayout Flashbar .当我删除这些库时,一切正常.删除库后,我的Gradle文件如下.

There were 4 third party libraries that broke my project : StickySwitch, ProgressView, SequenceLayout and Flashbar. When I removed those libraries, everything worked right. After removed the libraries, my Gradle file was as below.

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

那么,那些破坏我的项目的库的共同特征是什么?我的项目是用 Java 编写的,而库是用 Kotlin 编写的.一秒钟,我不能在Java项目中使用Kotlin库吗? 是的,我可以.我必须在 gradle.properties 中添加android.useAndroidX=trueandroid.enableJetifier=true,就是这样.但是,如果我已经在我的 gradle.properties 中添加了这些行,却没有效果怎么办?

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. One second, cannot I use Kotlin libraries in my Java project? Yes, I can. I have to add android.useAndroidX=true and android.enableJetifier=true in my gradle.properties, that is it. But what if I have already added those lines in my gradle.properties and it has not worked?

# 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

我不明白为什么kotlin库不能与我的Java项目一起使用.正如您在我的 Gradle文件中看到的那样,我正在使用apply plugin: 'kotlin-android'apply plugin: 'kotlin-android-extensions'来支持Kotlin.

I have not understood why kotlin libraries cannot work with my Java project. As you can see in my Gradle file, I am using apply plugin: 'kotlin-android' and apply plugin: 'kotlin-android-extensions' for Kotlin support.

我如何拯救我的项目?据我所知,有2个可用选项.第一种方法是删除这四个第三方库并且无法使用它们,第二种方法是将所有Java类转换为Kotlin类(我之前曾尝试过,但是直到禁用所有第三方库后,它才起作用).我选择将所有Java类都转换为Kotlin类.因此,我能够使用上面提到的4个第三方库.

How I have rescued my project? There were 2 available options as I knew. 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). I chose to convert all Java classes to Kotlin classes. Thus, I was able to use 4 third party libraries which were mentioned above.

我花了30天的时间解决了这个问题.现在,我正在研究Kotlin语言.结果,我的项目正在运行,没有任何问题.

It took me 30 days to solve this problem. Now, I am working on Kotlin language. As a result, my project is running without any problem.

这篇关于无法在Android Studio中执行复制粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆