无法在 Android Studio 中执行复制粘贴
Can Not Perform Copy-Paste in Android Studio
我在 Android Studio 中遇到了两个主要问题。首先我无法执行复制粘贴和剪切粘贴(ctrl+c - ctrl+v - ctrl+ x) 一些 classes 的能力。要解决该问题,我单击 "invalide caches/restarts",但它立即再次出现故障。
第二个问题是(我认为它与第一个问题有关)编译器不识别已经定义的方法和属性。自动建议等不起作用。
我尝试解决问题的步骤是;
- 文件 -> 无效 caches/restarts,
- 文件 -> 省电模式 -> 禁用,
- 关闭所有打开的选项卡并重新启动,
- 文件 -> 与 Gradle 个文件同步项目,
- 文件 -> 与文件系统同步,
- 删除JDK并重新安装,
- 删除 Android Studio 并重新安装,
- 删除已经下载的SDK文件和“.Android”文件夹,
- 禁用并删除所有插件。
- 在文件 -> 设置 -> 键盘映射中检查复制粘贴键盘映射
- 将项目从 bitbucket 拉到不同的 2 台计算机
- 新建项目,用NotePad++复制整个项目classes到
新项目
- 尝试将所有Java代码转换为Kotlin,无法转换
这是我的系统规格; Windows 10 家庭单一语言 (TR),版本 1909。16 GB 内存。 Android Studio 3.5.3 和 Gradle 版本 3.5.3
我已经阅读了关于相同问题的所有 post,但没有运气(post 仅关于 MAC 和 Linux 平台)。
更新 1.0 ->
我发现有些 classes 不能执行上述操作,但有些 classes 可以。
我意识到,没有 classes 的图标不能执行我上面描述的操作。 (有时会神奇地出现 "J" 图标,当我单击另一个 class 时,这个 J 图标会立即消失。)我认为 gradle 或 Android Studio 的文件系统无法识别这些文件作为 classes.
更新 2.0 ->
我注意到,当我单击 DuoFragment 的结构部分(其中有 500 多行代码和未编译的 class 之一)无法加载任何内容。 DuoFragment 的大小是否更大以进行处理?
另外我查看Build部分时,有些进程无法运行(不知道这是否正常);
- 任务:app:compileDebugAidl 无源,
- 任务:app:compileDebugRenderscript 无源,
- 任务 :app:processDebugJavaRes NO-SOURCE
更新 3.0 ->
这是我的 Gradle 文件。
项目级别 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
}
应用级别 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'
}
更新 1.0 图片
更新 2.0 图片
更新 --> Kotlin 库中存在 Windows 10 种单一语言土耳其语 的错误。 (也许其他一些单一语言 Windows 发行版也有同样的问题,我还不知道。)Kotlin 的一些库不能在土耳其操作系统上工作。我通过安装 Windows 10 Pro English.
解决了这个问题
其他使用 Windows 10 种单一语言土耳其语的开发人员从不同角度面临同样的问题。 ( and Example2)
旧答案
TL;DR -> 问题是关于用 Kotlin 编写的第三方库。我已将我的 Java 项目转换为 Kotlin,所有有问题的第三方库都运行良好。 问题是关于 Java - Kotlin 冲突。
我想分享一下我是如何解决这个问题的,以供以后遇到此类问题的人使用。
我一个一个地完成了上面提到的所有步骤,但我找不到任何解决方案,我决定检查我的第三方库。
首先,我禁用了所有第三方库并查看了我的 类 的状态,它无法识别已定义的方法和属性。在禁用第三方库并进行重建项目和同步 Gradle 后,那些损坏的 类 的自动建议功能开始工作 again.Then,发现哪些第三方库有问题,我激活了那些第三方库-派对图书馆一个接一个。我发现哪些第三方库破坏了我的项目。
有 4 个第三方库破坏了我的项目:StickySwitch, ProgressView, SequenceLayout and Flashbar。当我删除这些库时,一切正常。删除库后,我的 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'
}
那么,破坏我的项目的那些库的共同特征是什么?我的项目是用 Java 编写的,但是库是用 Kotlin 编写的。一秒钟,我不能在我的 Java 项目中使用 Kotlin 库吗? 。我必须在我的 gradle.properties 中添加 android.useAndroidX=true
和 android.enableJetifier=true
,就是这样。但是,如果我已经在我的 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
我不明白为什么 kotlin 库不能用于我的 Java 项目。正如您在我的 Gradle 文件 中看到的那样,我使用 apply plugin: 'kotlin-android'
和 apply plugin: 'kotlin-android-extensions'
来支持 Kotlin。
我是如何拯救我的项目的?据我所知,有 2 个可用选项。第一种方法是删除这 4 个第三方库并且无法使用它们,第二种方法是将所有 Java 类 转换为 Kotlin 类 (我之前尝试过但没有工作直到禁用所有第三方库)。我选择将所有 Java 类 转换为 Kotlin 类。因此,我能够使用上面提到的 4 个第三方库。
我花了 30 天时间才解决这个问题。现在,我正在研究 Kotlin 语言。结果,我的项目运行没有任何问题。
我在 Android Studio 中遇到了两个主要问题。首先我无法执行复制粘贴和剪切粘贴(ctrl+c - ctrl+v - ctrl+ x) 一些 classes 的能力。要解决该问题,我单击 "invalide caches/restarts",但它立即再次出现故障。
第二个问题是(我认为它与第一个问题有关)编译器不识别已经定义的方法和属性。自动建议等不起作用。
我尝试解决问题的步骤是;
- 文件 -> 无效 caches/restarts,
- 文件 -> 省电模式 -> 禁用,
- 关闭所有打开的选项卡并重新启动,
- 文件 -> 与 Gradle 个文件同步项目,
- 文件 -> 与文件系统同步,
- 删除JDK并重新安装,
- 删除 Android Studio 并重新安装,
- 删除已经下载的SDK文件和“.Android”文件夹,
- 禁用并删除所有插件。
- 在文件 -> 设置 -> 键盘映射中检查复制粘贴键盘映射
- 将项目从 bitbucket 拉到不同的 2 台计算机
- 新建项目,用NotePad++复制整个项目classes到 新项目
- 尝试将所有Java代码转换为Kotlin,无法转换
这是我的系统规格; Windows 10 家庭单一语言 (TR),版本 1909。16 GB 内存。 Android Studio 3.5.3 和 Gradle 版本 3.5.3
我已经阅读了关于相同问题的所有 post,但没有运气(post 仅关于 MAC 和 Linux 平台)。
更新 1.0 -> 我发现有些 classes 不能执行上述操作,但有些 classes 可以。
我意识到,没有 classes 的图标不能执行我上面描述的操作。 (有时会神奇地出现 "J" 图标,当我单击另一个 class 时,这个 J 图标会立即消失。)我认为 gradle 或 Android Studio 的文件系统无法识别这些文件作为 classes.
更新 2.0 -> 我注意到,当我单击 DuoFragment 的结构部分(其中有 500 多行代码和未编译的 class 之一)无法加载任何内容。 DuoFragment 的大小是否更大以进行处理?
另外我查看Build部分时,有些进程无法运行(不知道这是否正常);
- 任务:app:compileDebugAidl 无源,
- 任务:app:compileDebugRenderscript 无源,
- 任务 :app:processDebugJavaRes NO-SOURCE
更新 3.0 ->
这是我的 Gradle 文件。 项目级别 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
}
应用级别 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'
}
更新 1.0 图片
更新 2.0 图片
更新 --> Kotlin 库中存在 Windows 10 种单一语言土耳其语 的错误。 (也许其他一些单一语言 Windows 发行版也有同样的问题,我还不知道。)Kotlin 的一些库不能在土耳其操作系统上工作。我通过安装 Windows 10 Pro English.
解决了这个问题其他使用 Windows 10 种单一语言土耳其语的开发人员从不同角度面临同样的问题。 (
旧答案
TL;DR -> 问题是关于用 Kotlin 编写的第三方库。我已将我的 Java 项目转换为 Kotlin,所有有问题的第三方库都运行良好。 问题是关于 Java - Kotlin 冲突。
我想分享一下我是如何解决这个问题的,以供以后遇到此类问题的人使用。
我一个一个地完成了上面提到的所有步骤,但我找不到任何解决方案,我决定检查我的第三方库。
首先,我禁用了所有第三方库并查看了我的 类 的状态,它无法识别已定义的方法和属性。在禁用第三方库并进行重建项目和同步 Gradle 后,那些损坏的 类 的自动建议功能开始工作 again.Then,发现哪些第三方库有问题,我激活了那些第三方库-派对图书馆一个接一个。我发现哪些第三方库破坏了我的项目。
有 4 个第三方库破坏了我的项目:StickySwitch, ProgressView, SequenceLayout and Flashbar。当我删除这些库时,一切正常。删除库后,我的 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'
}
那么,破坏我的项目的那些库的共同特征是什么?我的项目是用 Java 编写的,但是库是用 Kotlin 编写的。一秒钟,我不能在我的 Java 项目中使用 Kotlin 库吗? android.useAndroidX=true
和 android.enableJetifier=true
,就是这样。但是,如果我已经在我的 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
我不明白为什么 kotlin 库不能用于我的 Java 项目。正如您在我的 Gradle 文件 中看到的那样,我使用 apply plugin: 'kotlin-android'
和 apply plugin: 'kotlin-android-extensions'
来支持 Kotlin。
我是如何拯救我的项目的?据我所知,有 2 个可用选项。第一种方法是删除这 4 个第三方库并且无法使用它们,第二种方法是将所有 Java 类 转换为 Kotlin 类 (我之前尝试过但没有工作直到禁用所有第三方库)。我选择将所有 Java 类 转换为 Kotlin 类。因此,我能够使用上面提到的 4 个第三方库。
我花了 30 天时间才解决这个问题。现在,我正在研究 Kotlin 语言。结果,我的项目运行没有任何问题。