Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy UI whole app gradle 8.1.2 #930

Closed
sucicf1 opened this issue Sep 29, 2023 · 16 comments
Closed

Legacy UI whole app gradle 8.1.2 #930

sucicf1 opened this issue Sep 29, 2023 · 16 comments

Comments

@sucicf1
Copy link

sucicf1 commented Sep 29, 2023

About this issue

  • When I put the code to use in only one module it works with the following workaround:
    implementation("com.mikepenz:aboutlibraries:10.8.3") {
    exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
    }
    But when I want to apply it to the whole app then it on synchronize gives an error without the above workaround or using the above workaround it gives a blank page in user interface of android app

Details

com.android.tools.build:gradle:8.1.2
id 'com.mikepenz.aboutlibraries.plugin' version "10.8.3"

@mikepenz
Copy link
Owner

mikepenz commented Oct 1, 2023

Can you please provide more details? Which error do you get?

@sucicf1
Copy link
Author

sucicf1 commented Oct 1, 2023

when I don't use the workaround sometimes I can sync and sometimes not the gradle files. But even if I can sync gradle files I get during building my apk the following error (similar error when I can't sync gradle files):

Duplicate class com.mikepenz.aboutlibraries.Libs found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.Libs$Builder found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.Libs$Builder$build$$inlined$sortedBy$1 found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.Developer found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.Funding found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.Library found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.License found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.Organization found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.entity.Scm found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)
Duplicate class com.mikepenz.aboutlibraries.util.Result found in modules jetified-aboutlibraries-core-jvm-10.8.3 (com.mikepenz:aboutlibraries-core-jvm:10.8.3) and jetified-aboutlibraries-core-release-runtime (com.mikepenz:aboutlibraries-core-android:10.8.3)

when I use the workaround I can sync gradle and build apk but running the app when it needs to display the package list it displays empty and in logcat I found the following:

Unable to read the library information
java.lang.IllegalStateException: Please provide the required library data via the available APIs.
Depending on the platform this can be done for example via LibsBuilder().withJson().
For Android there exists an LibsBuilder.withContext(), automatically loading the aboutlibraries.json file from the raw resources folder.
When using compose or other parent modules, please check their corresponding APIs.
at com.mikepenz.aboutlibraries.Libs$Builder.build(Libs.kt:37)
at com.mikepenz.aboutlibraries.viewmodel.LibsViewModel$listItems$1$1.invokeSuspend(LibsViewModel.kt:85)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

@mikepenz
Copy link
Owner

This looks to be like 2 different reports.

For the first: It seems the jettifier is somehow duplicating classes. Do you really still need the jettifier in your app?

For the second. Please make sure the plugin is properly applied, and the generation of the meta data works. (the build folder should contain the json output, unless you have it configured to manually generate the data?)

@sucicf1
Copy link
Author

sucicf1 commented Oct 13, 2023

Currently I have only one module and use the module wide solution. I can't remove jetifier without some medium work. On the other hand in the second case I see in logcat:
Unable to retrieve library information given the raw resource identifier.
Please make sure either the gradle plugin is properly set up, or the file is manually provided.
I am setting up the gradle plugin like following:

plugins {
    id 'com.mikepenz.aboutlibraries.plugin' version "10.8.3"
} 

Is that OK?

@sucicf1
Copy link
Author

sucicf1 commented Nov 11, 2023

I removed the jetifier and still get the duplicate class error.

@mikepenz
Copy link
Owner

Could it be possibly similar problem like: #881 (comment)

@dhoehl
Copy link

dhoehl commented Nov 13, 2023

I have the same issue on def latestAboutLibsRelease = '10.9.2.

    //implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}"
    //implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"

produces:
java.lang.ClassNotFoundException: Didn't find class "com.mikepenz.aboutlibraries.util.AndroidExtensionsKt"

Some more stack trace

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mikepenz/aboutlibraries/util/AndroidExtensionsKt;
at com.mikepenz.aboutlibraries.ui.LibsSupportFragment$viewModel$2.invoke(LibsSupportFragment.kt:54)
at com.mikepenz.aboutlibraries.ui.LibsSupportFragment$viewModel$2.invoke(LibsSupportFragment.kt:47)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:47)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
at com.mikepenz.aboutlibraries.ui.LibsSupportFragment.getViewModel(LibsSupportFragment.kt:47)
at com.mikepenz.aboutlibraries.ui.LibsSupportFragment.access$getViewModel(LibsSupportFragment.kt:42)
at com.mikepenz.aboutlibraries.ui.LibsSupportFragment$onCreateView$2$1$1.invokeSuspend(LibsSupportFragment.kt:95)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)

Using this workaround

implementation("com.mikepenz:aboutlibraries-core-android:${latestAboutLibsRelease}")
    implementation("com.mikepenz:aboutlibraries:${latestAboutLibsRelease}") {
        exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
    }

works, but the list of libraries is empty.

My build.gradle

buildscript {
....
}

plugins {
    id 'com.mikepenz.aboutlibraries.plugin' version "10.9.2"
}

App level

plugins {
    id 'com.mikepenz.aboutlibraries.plugin'
}

Code to call the library:

            new LibsBuilder()
                    .withAboutIconShown(true)
                    .withAboutVersionShown(true)
                    .withAboutDescription(getString(R.string.about_tv_main))
                    .withAboutSpecial1(getString(R.string.privacy_policy))
                    .withListener(...)
                    .start(this);

build/generated/aboutLibraries is empty

Unable to retrieve library information given the `raw` resource identifier. 
Please make sure either the gradle plugin is properly set up, or the file is manually provided. 
Unable to read the library information
java.lang.IllegalStateException: Please provide the required library data via the available APIs.
Depending on the platform this can be done for example via `LibsBuilder().withJson()`.
For Android there exists an `LibsBuilder.withContext()`, automatically loading the `aboutlibraries.json` file from the `raw` resources folder.
When using compose or other parent modules, please check their corresponding APIs.
	at com.mikepenz.aboutlibraries.Libs$Builder.build(Libs.kt:37)
	at com.mikepenz.aboutlibraries.viewmodel.LibsViewModel$listItems$1$1.invokeSuspend(LibsViewModel.kt:85)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Using Pixel6 API 33 for testing, java project.

Using library version 8.9.4 shows at least two items in the list: The AboutLibrary lib and FastAdapter (I guess used by AboutLibraries)

@mikepenz
Copy link
Owner

is the build/generated/aboutlibraries staying empty even when doing a clean build?

if you manually run the gradle task, would it have dependencies resolved?

./gradlew findLibraries

What gradle version are you using?

@dhoehl
Copy link

dhoehl commented Nov 14, 2023

Using Gradle 8.4.

./gradlew findLibraries

let to

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

Changing

#org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"

to

org.gradle.jvmargs=-Xmx1024m

in gradle.properties

solved this issue.

The library still isn't working after clean rebuild. (No build/generated/aboutlibraries folder available)

./gradlew findLibraries
Calculating task graph as no configuration cache is available for tasks: findLibraries

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.0.2.
     Required by:
         project :
      > No matching variant of com.android.tools.build:gradle:8.0.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.4' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:8.0.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.2 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:8.0.2 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.2 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
   > Could not resolve androidx.navigation:navigation-safe-args-gradle-plugin:2.7.1.
     Required by:
         project :
      > No matching variant of androidx.navigation:navigation-safe-args-gradle-plugin:2.7.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.4' but:
          - Variant 'apiElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.7.1 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'runtimeElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.7.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'sourcesElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.7.1 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
   > Could not resolve com.google.gms:google-services:4.4.0.
     Required by:
         project :
      > No matching variant of com.google.gms:google-services:4.4.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.4' but:    
          - Variant 'apiElements' capability com.google.gms:google-services:4.4.0 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'javadocElements' capability com.google.gms:google-services:4.4.0 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'runtimeElements' capability com.google.gms:google-services:4.4.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
          - Variant 'sourcesElements' capability com.google.gms:google-services:4.4.0 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2s
Configuration cache entry stored.

@dhoehl
Copy link

dhoehl commented Nov 16, 2023

When I try to build a realease build I also get this:

C:/Users/.../.gradle/caches/transforms-3/3da79f2f13a3f61c7d4287911f5a6908/transformed/aboutlibraries-10.9.2/jars/classes.jar!/META-INF/aboutlibraries.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

Project is written in java. Only external libraries might use kotlin. I do not have anything related to kotlin defined in my build.gradle files

@dhoehl
Copy link

dhoehl commented Nov 29, 2023

Please have a look on this MWE: https://github.com/dhoehl/LibraryTest

It demonstrates the crash if this code is not used:

implementation("com.mikepenz:aboutlibraries-core-android:${latestAboutLibsRelease}")
    implementation("com.mikepenz:aboutlibraries:${latestAboutLibsRelease}") {
        exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
    }

and it also demonstrates the missing json file (and resulting empty library screen. Simply change the build.gradle to reproduce both errors

    //Uncomment this and comment block (2) will let the app crash
    //Block (1)
    //implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}"
    //implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"

    //Uncomment this and comment block (1) so the app will start library screen but without any library present
    //Block (2)
    implementation("com.mikepenz:aboutlibraries-core-android:${latestAboutLibsRelease}")
    implementation("com.mikepenz:aboutlibraries:${latestAboutLibsRelease}") {
        exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
    }

@mikepenz
Copy link
Owner

mikepenz commented Dec 1, 2023

Thank you for this. I'll try to come to this as soon as possible

@dhoehl
Copy link

dhoehl commented Dec 1, 2023

I have some new insights:

Using this at top level gradle will reproduce the error (no json file in build folder)

plugins {
    id 'com.mikepenz.aboutlibraries.plugin' version "10.9.2"
}

But using this in top level gradle resp. in module gradle will produce the json file. In my MWE example this solves all issues and creates a full working library screen.

plugins {
    id 'com.mikepenz.aboutlibraries.plugin' version "10.9.2" apply false
}
plugins {
    id 'com.mikepenz.aboutlibraries.plugin'
}

In my production app this helped as well. The screen is not blank anymore and the app does not throw an exception. Nevertheless the json that is produced is empty. The build log gives me the following output for every library:

> Task :app:prepareLibraryDefinitionsDebug
--> Retrieved no components for: androidx.activity:activity:1.8.0
--> Retrieved no components for: androidx.activity:activity-ktx:1.8.0
--> Retrieved no components for: androidx.annotation:annotation-experimental:1.3.0
--> Retrieved no components for: androidx.annotation:annotation-jvm:1.6.0
--> Retrieved no components for: androidx.appcompat:appcompat:1.6.1
--> Retrieved no components for: androidx.appcompat:appcompat-resources:1.6.1
--> Retrieved no components for: androidx.arch.core:core-common:2.2.0
...

I could not figure out the difference between the MWE and my real app. But we are getting closer to a solution, I think.

I deleted .idea, .gradle and build dir still get the same result.

@dhoehl
Copy link

dhoehl commented Dec 1, 2023

Add this org.gradle.unsafe.configuration-cache=false to your gradle.properties file. With the above fix and workarounds the library works again finally.

So it was the gradle configuration cache after all

@mikepenz
Copy link
Owner

mikepenz commented Dec 2, 2023

Thank you for the update @dhoehl

@mikepenz
Copy link
Owner

mikepenz commented Jan 6, 2024

Closing as config cache problems are tracked here: #839

@mikepenz mikepenz closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants