Android Studio doesn't parse/recognize java files

Viewed 22

I have a very weird problem with Android Studio Chipmunk. It doesn't recognize java syntax and all IDE features are disabled, like autocomplete, autoimports, etc., but only in one of my projects. If I open other projects It works good, but with one of them It doesn't work. It's like the project were only c++, because if I try to create a new class (right button -> New), only "c++ class" is shown, and "java class" option is missing.
I have tried all answers I have found in stackoverflow but without success:

  • Invalidate caches and restart
  • Clean, rebuild, make.
  • Check Power save mode is unchecked.
  • Delete .idea folders, and other folders like .gradle, etc.
  • Rename some folders in users//appdata/local...android
  • File -> sync project with gradle files
  • Update all dependencies in gradle file to latest versions.
  • Check gradle-wrapper.properties

I don't know what else I could do. This is my build.gradle, but ask me for another file if it were required.

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath 'com.google.gms:google-services:4.3.13'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
    }
}

apply plugin: 'com.android.application'

repositories{
    mavenCentral()
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://maven.google.com" }  // <<<< REPOSITORY HERE
        maven { url 'https://maven.fabric.io/public' }
    }
}

apply plugin: 'com.android.application'

dependencies {

    implementation 'com.google.firebase:firebase-crashlytics:18.2.13'
    implementation 'com.google.firebase:firebase-analytics:21.1.1'
    implementation 'com.google.firebase:firebase-messaging:23.0.8'
    implementation files('libs/ZSDK_ANDROID_API.jar')
    implementation files('libs/ZSDK_ANDROID_BTLE.jar')
    def acraVersion = '5.9.6'
    
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.jpardogo.materialtabstrip:library:1.1.1'
    implementation 'androidx.appcompat:appcompat:1.5.0'
    implementation 'com.github.shell-software:fab:1.1.2'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.github.rey5137:material:1.3.1'
    implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'

    implementation 'com.google.android.gms:play-services-vision:20.1.3'
    implementation 'androidx.mediarouter:mediarouter:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.5.0'
    implementation 'com.google.firebase:firebase-core:21.1.1'
    implementation "androidx.viewpager:viewpager:1.0.0"

    // this line must be included to use FCM
    implementation 'androidx.multidex:multidex:2.0.1'
    // ACRA
    implementation "ch.acra:acra-mail:$acraVersion"
    implementation "ch.acra:acra-dialog:$acraVersion"

    // Debug implementation base de datos
    debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

}

android {
    compileSdkVersion 33
    buildToolsVersion '33.0.0'

    defaultConfig {
        applicationId "com.mycompany.myproject"
        targetSdkVersion 33
        minSdkVersion 19
        setProperty("archivesBaseName", "myproject")
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

    compileOptions.encoding "ISO-8859-1" // For Spanish [Otherwise strange accents]

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    // Specifies a flavor dimension.
    flavorDimensions "color"

    productFlavors {
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        androidTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }

    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }

    signingConfigs {
        release {
            v2SigningEnabled false
        }
    }

    android {
        lintOptions {
            abortOnError false
        }
    }

    packagingOptions {
        resources {
            excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES']
        }
    }
    ndkVersion '25.1.8937393'

}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
0 Answers
Related