The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten

Viewed 569

I'm learning developing app for android. In particular, how it works a mediaplayer. The target system should be android for automotive. For this reason I have downloaded a sample UAMP application from google but, unfortunately, doesn't compile, it is too old. So I decided to rebuild a project and importe all the modules. For me is important understand how it works! Anyway, I have imported all libraries, in gradle and in the modules, I have compiled the automotive version of the app and I have this message:

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

In detail, the gradle explains:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':automotive:mergeDebugJavaResource'.

 Could not resolve all files for configuration ':automotive:debugRuntimeClasspath'.
Failed to transform kotlin-android-extensions-1.3.41.jar (org.jetbrains.kotlin:kotlin-android-extensions:1.3.41) to match attributes {artifactType=android-java-res, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: C:\Users\James Tiberius Kirk\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions\1.3.41\3bb1958b60435763b1299eb4e2dea5bea3bab2a3\kotlin-android-extensions-1.3.41.jar.
         > Failed to transform 'C:\Users\James Tiberius Kirk\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions\1.3.41\3bb1958b60435763b1299eb4e2dea5bea3bab2a3\kotlin-android-extensions-1.3.41.jar' using Jetifier. Reason: AmbiguousStringJetifierException, message: The given artifact contains a string literal with a package reference 'android.support.v4' 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.)
           This is a known exception, and Jetifier won't be able to jetify this library.
>

Ok, sorry for my poor english, but the problem is quite complex and my english is not so advanced. The project for automotive is composed by three branches, the mobile app, the automotive app and a shared branch. Now I am working on the automotive branch, and its includes the shared branch. The first thing I did was check if may be one or more included libraries were not the last release. And as I can understand all the libraries are the last version and compatible with androidx (my target system) here the list of include libraries on the Automotive branch:

>
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
    implementation "androidx.core:core-ktx:1.2.0"
    implementation "androidx.constraintlayout:constraintlayout:1.1.3"
    implementation "androidx.appcompat:appcompat:1.1.0"
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.preference:preference:1.1.1"
    androidTestImplementation "androidx.test.ext:junit:1.1.1"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
    implementation "com.google.android.exoplayer:extension-mediasession:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-core:2.11.4"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
    implementation "com.github.bumptech.glide:glide:4.11.0"
    implementation "com.google.gms:google-services:4.3.3"
    implementation 'com.google.android.gms:play-services-drive:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.google.apis:google-api-services-gmail:v1-rev72-1.23.0'
    implementation 'com.google.android.material:material:1.2.0-alpha06'


    implementation project(path: ':shared')

}

In the shared branch the included libraries are:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
    implementation 'androidx.media:media:1.1.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
    implementation "com.google.android.exoplayer:extension-mediasession:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-core:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-dash:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-ui:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-hls:2.11.4"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:2.11.4"
    implementation "com.github.bumptech.glide:glide:4.11.3"

}

So, I have tryed any thing I know, but the issue is still there. Is there anyone, that can give me a suggestion, an Idea, something that can help me to solve this problem and proceed on the training? Thanks a lot for any contribute.

1 Answers

The UAMP version1 is not supported anymore, and will not work because a lot of things in it are deprecated. my advice is don't import the project and change it. you need to build your own from the ground up.

Related