Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error: Failed to transform file to match attributes jetified

I have set up a pipeline that runs my tests in microsoft azure pipelines. On my local machine this works fine and the jetified-libidpmobile-debug.jar file is found in the gradle system directory on my machine:

/Users/jimclermonts/.gradle/caches/transforms-2/files-2.1/efad9765ab457848824459e0c76abddc/jetified-libidpmobile-debug.jar

this is my build.gradle:

debugImplementation files('libs/libidpmobile-debug.jar')

From what I understand, jetified-libidpmobile-debug.jar is automatically created by jetifier from the libidpmobile-debug.jar file.

Output:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Could not resolve all files for configuration ':app:_classStructurekaptDebugKotlin'.
   > Failed to transform file 'jetified-libidpmobile-debug.jar' to match attributes {artifactType=class-structure, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
      > Execution failed for StructureArtifactTransform: /Users/iosadmin/.gradle/caches/transforms-2/files-2.1/1e14bb7ec832a0c2c967e6c977ddd9b9/jetified-libidpmobile-debug.jar.
         > error in opening zip file

Here is the part of my azure-pipelines.yml that assembles the debug and tests the unit tests:

trigger:
- master

pool:
  name: Mobile-Pool

steps:
- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx4096m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'assembleDebug testDebugUnitTest'

I tried the solutions in this post, this post and this post with no result. The jar file is 4mb big and is the only file that is in the code repository instead of some maven repository.

Updated Gradle to the latest:

classpath 'com.android.tools.build:gradle:4.0.0-beta05'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Tried to edit the androidmanifest like this:

tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx.core.app.CoreComponentFactory">

build.gradle:

kotlinOptions {
    jvmTarget = '1.8'
}

compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
}
like image 587
Jim Clermonts Avatar asked Nov 07 '22 07:11

Jim Clermonts


1 Answers

I used jetifier-standalone to jetify the files. Added it to gradle.properties:

android.jetifier.blacklist = libidpmobile

and now it works.

like image 101
Jim Clermonts Avatar answered Nov 14 '22 21:11

Jim Clermonts