Sonarqube integration in Android project / errors

Hello there,

I have integrated SonarQube into my Android project. However, when I use the .\gradlew.bat sonarqube command, I encounter an error that causes the SonarQube job to start and then get stuck in a loop. After approximately 10-15 minutes, the task eventually finishes and displays the results.

Please help me resolve this issue.

Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared fields org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files
Status ERROR: org.eclipse.jdt.core code=4 Could not retrieve declared methods org.eclipse.jdt.internal.compiler.problem.AbortCompilation: Pb(324) The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:70)
	at org.gradle.internal.Either$Right.fold(Either.java:175)
	at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:68)
	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:46)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:36)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:25)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:91)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:55)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:37)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:65)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:36)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:77)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:38)
	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:94)
	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:49)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:71)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:45)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.executeWithNonEmptySources(SkipEmptyWorkStep.java:177)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:81)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:53)
	at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:32)
	at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:21)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
	at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:36)
	at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:23)

Hey there.

Are you, by any chance, using OpenHFT/Java Thread Affinity/affinity in your project?

thank you for answer
No i’m not using OpenHFT/Java Thread Affinity/affinity in my project

Thanks.

Would you be able to share your list of gradle dependencies?

    androidXDependencies = [
            appcompat       : "androidx.appcompat:appcompat:$appcompatVersion",
            core            : "androidx.core:core-ktx:$coreKtx",
            constraintlayout: "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion",
            support         : "androidx.legacy:legacy-support-v4:$legacySupportV4Version",
            activity        : "androidx.activity:activity-ktx:$activityKtxVersion",
            fragment        : "androidx.fragment:fragment-ktx:$fragmentKtxVersion",
            recyclerview    : "androidx.recyclerview:recyclerview:$recyclerviewVersion",
    ]

    googleDependencies = [
            material: "com.google.android.material:material:$materialVersion",
            playCore: "com.google.android.play:core:$playCoreVersion",
            gson    : "com.google.code.gson:gson:$gsonVersion"

    ]

    googlePlayServicesDependencies = [
            mapsUtils               : "com.google.maps.android:android-maps-utils:$mapsUtilsVersion",
            playServicesBase        : "com.google.android.gms:play-services-base:$playServicesBaseVersion",
            playServicesMaps        : "com.google.android.gms:play-services-maps:$playServicesMapsVersion",
            playServicesLocation    : "com.google.android.gms:play-services-location:$playServicesLocationVersion",
            playServicesAuth        : "com.google.android.gms:play-services-auth:$playServicesAuthVersion",
            playServicesAuthApiPhone: "com.google.android.gms:play-services-auth-api-phone:$playServicesAuthApiPhoneVersion",
    ]

    navigationDependencies = [
            navigationFragment: "androidx.navigation:navigation-fragment-ktx:$navigationVersion",
            navigationUi      : "androidx.navigation:navigation-ui-ktx:$navigationVersion",
            navigationruntime : "androidx.navigation:navigation-runtime-ktx:$navigationVersion"
    ]

    firebaseDependencies = [
            firebaseCore       : "com.google.firebase:firebase-core:$firebaseCore",
            firebaseAnalytics  : "com.google.firebase:firebase-analytics",
            firebaseCrashlytics: "com.google.firebase:firebase-crashlytics:$firebaseCrashlytics",
            firebaseMessaging  : "com.google.firebase:firebase-messaging:$firebaseMessaging",
    ]

    koinDependencies = [
            koinAndroid            : "io.insert-koin:koin-android:$koinVersion",
            koinAndroidxWorkmanager: "io.insert-koin:koin-androidx-workmanager:$koinVersion"
    ]
    roomDependencies = [
            roomKtx    : "androidx.room:room-ktx:$roomVersion",
            roomRuntime: "androidx.room:room-runtime:$roomVersion",
            sqlcipher  : "net.zetetic:android-database-sqlcipher:4.5.3",
    ]

    roomWithRxJavaDependencies = [
            roomRxjava2: "androidx.room:room-rxjava2:$roomVersion",
            roomRuntime: "androidx.room:room-runtime:$roomVersion",
            sqlcipher  : "net.zetetic:android-database-sqlcipher:4.5.3",
            rxjava2    : "io.reactivex.rxjava2:rxjava:2.1.14",
            rxandroid  : "io.reactivex.rxjava2:rxandroid:2.0.2",
            roomKtx    : "androidx.room:room-ktx:$roomVersion",
    ]

    networkDependencies = [
            retrofit          : "com.squareup.retrofit2:retrofit:$retrofitVersion",
            converterGson     : "com.squareup.retrofit2:converter-gson:$retrofitVersion",
            okhttp            : "com.squareup.okhttp3:okhttp:$okHttpVersion",
            interceptor       : "com.squareup.okhttp3:logging-interceptor:$okHttpVersion",
            readystatesoftware: "com.github.chuckerteam.chucker:library:$chuckerVersion",
    ]

liveDataVMDependencies = [
            lifecycleExtensions: "androidx.lifecycle:lifecycle-extensions:$lifecycleExtensionsVersion",
            lifecycleViewmodel : "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion",
            lifecycleLivedata  : "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion",
            lifecycleRuntime   : "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion",
            liveEvent          : "com.github.hadilq:live-event:$liveEventVersion",
    ]

    // Coroutine dependencies
    kotlinCoroutineVersion = '1.6.4'
    coroutineDependencies = [
            kotlinxCoroutinesAndroid: "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutineVersion",
            kotlinxCoroutinesCore   : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutineVersion",
    ]

    // Media dependencies
    glideVersion = '4.15.1'
    gifVersion = '1.2.18'
    picassoVersion = '2.5.2'
    lottieVersion = '5.2.0'
    mediaDependencies = [
            glide  : "com.github.bumptech.glide:glide:$glideVersion",
            gif    : "pl.droidsonroids.gif:android-gif-drawable:$gifVersion",
            picasso: "com.squareup.picasso:picasso:$picassoVersion",
            lottie : "com.airbnb.android:lottie:$lottieVersion",
    ]

    //Acuant dependencies for biometric registration
    acuantVersion = '11.5.4'
    acuantDependencies = [
            acuantcommon            : "com.acuant:acuantcommon:$acuantVersion",
            acuantcamera            : "com.acuant:acuantcamera:$acuantVersion",
            acuantimagepreparation  : "com.acuant:acuantimagepreparation:$acuantVersion",
            acuantdocumentprocessing: "com.acuant:acuantdocumentprocessing:$acuantVersion",
            acuantechipreader       : "com.acuant:acuantechipreader:$acuantVersion",
            acuantfacematch         : "com.acuant:acuantfacematch:$acuantVersion",
            acuantfacecapture       : "com.acuant:acuantfacecapture:$acuantVersion",
            acuantpassiveliveness   : "com.acuant:acuantpassiveliveness:$acuantVersion",
    ]

    //Camera dependencies
    cameraXVersion = '1.3.0-rc01'
    acbaCameraVersion = '1.0.2'
    cameraXDependencies = [
            core      : "androidx.camera:camera-core:$cameraXVersion",
            camera2   : "androidx.camera:camera-camera2:$cameraXVersion",
            lifecycle : "androidx.camera:camera-lifecycle:$cameraXVersion",
            view      : "androidx.camera:camera-view:$cameraXVersion",
            acbaCamera: "com.github.vahe9990:AcbaCamera:$acbaCameraVersion",
    ]

    spongycastleVersion = '1.54.0.0'
    spongycastleVersionCore = '1.58.0.0'
    spongycastleDependencies = [
            pkix: "com.madgag.spongycastle:pkix:$spongycastleVersion",
            core: "com.madgag.spongycastle:core:$spongycastleVersionCore",
            prov: "com.madgag.spongycastle:prov:$spongycastleVersionCore",
            pg  : "com.madgag.spongycastle:pg:$spongycastleVersion",
    ]

    zxingAndroidVersion = '3.5.0'
    zxingBarcodeScannerVersion = '1.9.13'
    zxingCoreVersion = '3.3.3'
    zxingDependencies = [
            zxingAndroid       : "com.journeyapps:zxing-android-embedded:$zxingAndroidVersion",
            zxingCore          : "com.google.zxing:core:$zxingCoreVersion",
            zxingBarcodeScanner: "me.dm7.barcodescanner:zxing:$zxingBarcodeScannerVersion",
    ]

    DMNetworkingVersion = '1.2.8'
    DMUtilsVersion = '1.0.2'
    DMNetworking = [
            DMNetworking: "com.github.pmbfish40:DMNetworking:$DMNetworkingVersion",
            DMUtils     : "com.github.pmbfish40:DMUtils:$DMUtilsVersion"
    ]

    // Third party dependencies
    ccpVersion = '2.6.1'
    ccp = "com.hbb20:ccp:$ccpVersion"

    joielechongccpVersion = '2.2.0'
    joielechongccp = "com.github.joielechong:countrycodepicker:$joielechongccpVersion"

    keyboardVisibilityEventVersion = '3.0.0-RC3'
    keyboardVisibilityEvent = "net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:$keyboardVisibilityEventVersion"

    biometricVersion = '1.1.0'
    biometric = "androidx.biometric:biometric:$biometricVersion"

    jnaVersion = '5.13.0@aar'
    jna = "net.java.dev.jna:jna:$jnaVersion"

    workManagerVersion = '2.8.1'
    workManager = "androidx.work:work-runtime-ktx:$workManagerVersion"

    rangeSeekbarVersion = '1.1.3'
    rangeSeekbar = "com.crystal:crystalrangeseekbar:$rangeSeekbarVersion"

    pagingKtxVersion = '3.1.1'
    paging = "androidx.paging:paging-runtime-ktx:$pagingKtxVersion"

    jsoupVersion = '1.16.1'
    jsoup = "org.jsoup:jsoup:$jsoupVersion"

    jacksonVersion = '2.11.1'
    jackson = "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"

    realtimeBlurViewVersion = '1.2.1'
    realtimeBlurView = "com.github.mmin18:realtimeblurview:$realtimeBlurViewVersion"

    tooltipVersion = '0.2.2'
    tooltip = "com.github.douglasjunior:android-simple-tooltip:$tooltipVersion"

    expandableLayoutVersion = '2.9.2'
    expandableLayout = "net.cachapa.expandablelayout:expandablelayout:$expandableLayoutVersion"

    pageIndicatorViewVersion = '1.0.3'
    pageIndicatorView = "com.romandanylyk:pageindicatorview:$pageIndicatorViewVersion"

    singleDateAndTimePickerVersion = '2.2.7'
    singleDateAndTimePicker = "com.github.florent37:singledateandtimepicker:$singleDateAndTimePickerVersion"

    textDrawableVersion = '1.0.1'
    textDrawable = "com.amulyakhare:com.amulyakhare.textdrawable:$textDrawableVersion"

    multidexVersion = '2.0.1'
    multidex = "androidx.multidex:multidex:$multidexVersion"

    autoImageSliderVersion = '1.4.0'
    autoImageSlider = "com.github.smarteist:autoimageslider:$autoImageSliderVersion"

    coverflowVersion = 'release-v1.0.5'
    coverflow = "com.github.crosswall:Android-Coverflow:$coverflowVersion"

    kspRoom = "androidx.room:room-compiler:$roomVersion"
    kspGlide = "com.github.bumptech.glide:ksp:$glideVersion"

    annotationProcessorDependencies = [
            room : "androidx.room:room-compiler:$roomVersion",
            glide: "com.github.bumptech.glide:compiler:$glideVersion",
    ]

    // Classpath dependencies
    firebaseCrashlyatics = '2.9.0'
    classpathDependencies = [
            firebaseCrashlyatics: "com.google.firebase:firebase-crashlytics-gradle:$firebaseCrashlyatics",
            naviagationSafeArgs : "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion",
            sonarsource         : "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373"
    ]

    // Test dependencies
    testDependencies = [
            junit               : 'junit:junit:4.13.2',
            androidxTestExt     : 'androidx.test.ext:junit:1.1.3',
            androidxTestEspresso: 'androidx.test.espresso:espresso-core:3.4.0'
    ]
}

Thanks. And sorry – one more question (I realized it’s not in your post), what version of SonarQube are you using?

no problem, thank you too for helping, SonarQube version is 9.9.2, plugin version is 4.4.1.3373

Hi @awsmman,

Thanks for your report this is a known issue on our side. Here is the ticket: [SONARJAVA-4697] - Jira We’re currently working on the fix.

You can read the ticket description to understand better what’s happening. In simple words to analyze your Java files we use an Eclipse compiler that is more strict with some JLS violations than the one you’re using to build your project. So if you try to build your project with an Eclipse compiler you’d probably face this issue. However, since you’re not using it, this shouldn’t break the analysis.

Meanwhile, the workaround is to set the property sonar.java.jdkHome to use Jdk8. This won’t affect the Java version you’re using. This might only affect the JDK classes in your classpath. This is a temporary workaround, that you won’t need once we deploy the fix.

Sorry for the inconvenience.

Best,
Margarita

hi @Margarita_Nedzelska

thank you for answering, its fixed right?

Hey @awsmman

The fix should make its way into SonarQube v10.4 in mid-January, and onto SonarCloud soon.

Is the fix on SonarCloud yet? I’m getting these errors, using the gradle plugin “org.sonarqube” version “4.4.1.3373” with Java 17. Will the fix require an updated gradle plugin?

No, you need to use the property sonar.java.jdkHome, and jdkHome can be the path to JDK 17 too. It’s working finally.

1 Like

We have a dependency that needs to be unblocked before we can deploy it to SonarCloud. Sorry about the wait.

I am not using the Sonar Cloud version

I was replying to @jseletz :slight_smile:

@Colin Thanks for the reply. We don’t want to install/use Jdk8 in the build environment, so we prefer to wait for this to be fixed for SonarCloud. Once the fix is deployed to SonarCloud, will the errors just stop, or will we need to make any changes to our build/client? Also how can we be informed when this fix is deployed? Thanks.

I believe the errors should just stop You will need to add a configuration parameter which will be announced/documented.

There’s not really a mechanism to know when this specific ticket is deployed to SonarCloud, but I’ll keep this thread bookmarked and check in over the next few weeks.

Any update on this?

@Colin Any update on this?

Not yet! Sorry.