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

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

问题描述

我在 Android Studio 中遇到了两个主要问题.首先我不能执行复制粘贴剪切粘贴(ctrl+c - ctrl+v - ctrl+x) 某些职业的能力.为了解决这个问题,我点击了invalide caches/restarts",但它立即再次崩溃.

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,无法转换

这是我的系统规格;Windows 10 家庭单语言 (TR),版本 1909.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).

更新 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.

更新 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?

另外在查看Build部分时,有些进程无法运行(不知道是否正常);

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

更新 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 图片

推荐答案

UPDATE --> Windows 10 单语言土耳其语 的 Kotlin 库中存在一个错误.(也许其他一些单语言 Windows 发行版也有同样的问题,我还不知道.)Kotlin 的一些库不能在土耳其语操作系统上运行.我通过安装 Windows 10 Pro English 解决了这个问题.

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 单语言土耳其语的开发人员在不同的角度面临同样的问题.(示例 1示例 2一>)

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 个第三方库破坏了我的项目:StickySwitchProgressView, SequenceLayoutFlashbar.当我删除这些库时,一切正常.删除库后,我的 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 个可用选项.第一种方法是删除这 4 个第三方库而无法使用它们,第二种方法是将所有 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天全站免登陆