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;
- File -> invalide caches/restarts,
- File -> Power Save Mode -> Disable,
- Close all opened tabs and fresh restart,
- File -> Sync Project with Gradle Files,
- File -> Sync with File System,
- Delete JDK and reinstall,
- Delete Android Studio and reinstall,
- Delete already downloaded SDK files and ".Android" folder,
- Disable and delete all plugins.
- Checked copy-paste keymap in File -> Settings -> Keymap
- Pulled the project from bitbucket to different 2 computers
- Created new project, copy whole project classes with NotePad++ to new Project
- Try to convert all Java codes to Kotlin, cannot convert
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
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 -> I have discovered that some classes cannot do the operations described above, but some classes can.
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 -> 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);
- Task :app:compileDebugAidl NO-SOURCE,
- Task :app:compileDebugRenderscript NO-SOURCE,
- Task :app:processDebugJavaRes NO-SOURCE
UPDATE 3.0 ->
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
}
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'
}
UPDATE 1.0 Images
UPDATE 2.0 Images
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.
Other developers who use Windows 10 Single Language Turkish faces same problem with diffirent angles. (Example1 and Example2)
OLD ANSWER
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.
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.
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.
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
andandroid.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?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'
andapply plugin: 'kotlin-android-extensions'
for Kotlin support.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.
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.
I suggest you to open it on another computer by pulling it from bitbucket, and see if it's acts the same