我正在学习为Android开发应用程序。特别是媒体播放器的工作方式。目标系统应该是用于汽车的android。因此,我已经从Google下载了示例UAMP应用程序,但不幸的是,它没有编译,它太旧了。因此,我决定重建一个项目并导入所有模块。对我来说重要的是了解它是如何工作的!无论如何,我已经在gradle和模块中导入了所有库,已经编译了该应用程序的汽车版本,并且收到以下消息:

*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*.


详细地,gradle解释了:

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.
>


好的,对不起我的英语不好,但是问题很复杂,我的英语还不够高级。汽车项目由三个分支组成:移动应用程序,汽车应用程序和一个共享分支。现在,我在汽车部门工作,其中包括共享分支。
我做的第一件事是检查是否可能一个或多个包含的库不是最新版本。据我了解,所有库都是最新版本,并且与androidx(我的目标系统)兼容,这里是Automotive分支中的包含库列表:

>
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')

}


在共享分支中,包括的库是:

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"

}


因此,我尝试了任何我知道的事情,但是问题仍然存在。有没有人可以给我一个建议,一个主意,可以帮助我解决这个问题并继续进行培训?
非常感谢您的贡献。

最佳答案

UAMP version1不再受支持,并且因为其中许多内容已被弃用而无法使用。我的建议是不要导入项目并进行更改。您需要从头开始构建自己的。

10-04 23:12
查看更多