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

Missing AndroidX support? #201

Closed
ReneFerrari opened this issue Jul 4, 2019 · 4 comments
Closed

Missing AndroidX support? #201

ReneFerrari opened this issue Jul 4, 2019 · 4 comments
Labels

Comments

@ReneFerrari
Copy link

State your question
I have created a new project with AndroidX and Jetifier enabled and only added the AWSAppSync dependency. When I built the App I had been facing the following error:

The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

More detailed:

org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:checkDebugDuplicateClasses'.
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: java.lang.RuntimeException: Failed to transform '/Users/dev/.gradle/caches/modules-2/files-2.1/com.android.tools/common/26.2.1/b1b9e1a6efa7b64cba484e9f6562b5f63bf23e22/common-26.2.1.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
Caused by: com.android.tools.build.jetifier.processor.transform.bytecode.AmbiguousStringJetifierException: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

Provide code snippets (if applicable)
My current solution is the following:

gradle.properties

org.gradle.jvmargs=-Xmx1536m
android.enableJetifier=true
android.jetifier.blacklist=android.tools.common
kotlin.code.style=official

build.gradle (app)

apply plugin: 'com.android.application'
apply plugin: 'com.amazonaws.appsync'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "<id>"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
    }
}

dependencies {
    implementation "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:$aws_version"
    implementation "com.amazonaws:aws-android-sdk-appsync:$aws_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

(All I did was add dependencies for AppSync and exclude Meta/Inf so the build won't fail)

build.gradle (project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.40'
    ext.aws_version = '2.10.0'

    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:$aws_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Environment(please complete the following information):

  • AppSync SDK Version: 2.10.0
  • AndroidStudio 3.4.1

My question is is there a better way to integrate AWSAppSync when using AndroidX? My current solution feels very hacky.

@s-ayush2903
Copy link

exclude Meta/Inf

@ReneFerrari Can you please explain addition of
packagingOptions { exclude 'META-INF/DEPENDENCIES' }

BTW, the soln worked for me, thanks!!!!!!!!!!!!11

@kelvinharron
Copy link

Is someone able to comment on an update to this, please? This is the last library in our project needing the jetifier. As highlighted by canIDropJetifier:

========================================
Project app
========================================

Cannot drop Jetifier due to following module dependencies:

* app (module)
  \-- com.amazonaws:aws-android-sdk-appsync:3.1.4
   \-- android.arch.lifecycle:runtime:1.1.1
  \-- net.grandcentrix.tray:tray:0.12.0
   \-- com.android.support:support-annotations:26.1.0

Cannot drop Jetifier due to following external dependencies:

* com.amazonaws:aws-android-sdk-appsync:3.1.4
  \-- android.arch.lifecycle:runtime:1.1.1

* net.grandcentrix.tray:tray:0.12.0
  \-- com.android.support:support-annotations:26.1.0

I hope the output is useful. Thanks.

@baksansk
Copy link
Contributor

baksansk commented Nov 1, 2021

A PR to migrate to AndroidX was merged and waiting for the next release.

@eeatonaws
Copy link
Contributor

A PR to migrate to AndroidX was released as part of version 3.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants