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

androidx.browser:browser new version causing android crash #298

Closed
MFrat opened this issue Sep 16, 2021 · 3 comments
Closed

androidx.browser:browser new version causing android crash #298

MFrat opened this issue Sep 16, 2021 · 3 comments

Comments

@MFrat
Copy link

MFrat commented Sep 16, 2021

Due to this code section in build.gradle:

  if (supportLibVersion && androidXVersion == null) {
    implementation "com.android.support:support-annotations:$supportLibVersion"
    implementation "com.android.support:customtabs:$supportLibVersion"
  } else {
    def defaultAndroidXVersion = "1.+"
    if (androidXVersion == null) {
      androidXVersion = defaultAndroidXVersion
    }
    def androidXAnnotation = safeExtGet('androidXAnnotation', androidXVersion)
    def androidXBrowser = safeExtGet('androidXBrowser', androidXVersion)
    implementation "androidx.annotation:annotation:$androidXAnnotation"
    implementation "androidx.browser:browser:$androidXBrowser"
  }

This crash occurs:

* What went wrong:
Execution failed for task ':app:checkDevDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > The minCompileSdk (31) specified in a
     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
     is greater than this module's compileSdkVersion (android-29).       
     Dependency: androidx.browser:browser:1.4.0-alpha01.
     AAR metadata file: xxx\.gradle\caches\transforms-2\files-2.1\41d31c04c2da61351e7148be9705c286\browser-1.4.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.

I think it is not a good practice to set a version with +, it should be a fixed stable version, like:

def defaultAndroidXAnnotation = "1.2.0"
def defaultAndroidXBrowser = "1.3.0"

def androidXAnnotation = safeExtGet('androidXAnnotation', defaultAndroidXAnnotation)
def androidXBrowser = safeExtGet('androidXBrowser', defaultAndroidXBrowser)

implementation "androidx.annotation:annotation:$androidXAnnotation"
implementation "androidx.browser:browser:$androidXBrowser"

To fix this without depending on a new version of this library, add this:

    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
        kotlinVersion = "1.3.72"
        androidXBrowser = "1.3.0" // Adding this property will avoid defaultAndroidXVersion
    }
@MFrat MFrat closed this as completed Sep 16, 2021
@tindn
Copy link

tindn commented Sep 18, 2021

@MFrat Thank you for detailing a fix in the meantime

@ArturTimoxin
Copy link

ArturTimoxin commented Sep 20, 2021

@MFrat Thank you it helped me a lot! I had the error in the Android Studio

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30).

This line androidXBrowser = "1.3.0" resolved my problem with this. androidXBrowser just got new version, but version 1.3.0 is better for me.

@csantarin
Copy link

@MFrat found the same problem, found the same solution.

But why close this, though? This fix should be forwarded to a PR...

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

4 participants