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

Build fails with androidX and jetifier enabled #1395

Closed
j-ns opened this issue Oct 30, 2018 · 30 comments
Closed

Build fails with androidX and jetifier enabled #1395

j-ns opened this issue Oct 30, 2018 · 30 comments

Comments

@j-ns
Copy link

j-ns commented Oct 30, 2018

I migrated my project to androidX. Now I get the following error message on building the project:

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

Caused by: java.lang.RuntimeException: Failed to transform butterknife-compiler-9.0.0-rc1.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

gradle.properties:

...
android.useAndroidX=true
android.enableJetifier=true

build.gradle (app module)

...
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

 buildToolsVersion '28.0.3'

implementation 'com.jakewharton:butterknife:9.0.0-rc1'
kapt 'com.jakewharton:butterknife-compiler:9.0.0-rc1'

gradle distribution: gradle-4.10.2

I've tried using different versions of the artifacts, still getting the same error

@JakeWharton
Copy link
Owner

Well that's stupid. I guess I'll just fool it's logic by splitting the string into two.

@JakeWharton
Copy link
Owner

Please test the SNAPSHOT build in about 20m. If this doesn't work I'm going to revert and ask you to file a jetifier bug.

@j-ns
Copy link
Author

j-ns commented Oct 30, 2018

What's the version, 9.0.0-SNAPSHOT?

@JakeWharton
Copy link
Owner

JakeWharton commented Oct 30, 2018 via email

@j-ns
Copy link
Author

j-ns commented Oct 30, 2018

Doesn't work. Still the same error message showing up.
I filed a bug in the google issue tracker

@JakeWharton
Copy link
Owner

Link your bug

@j-ns
Copy link
Author

j-ns commented Oct 31, 2018

@JakeWharton
Copy link
Owner

Thanks!

@edouardlib
Copy link

I have the same bug and I can't find a way to resolve it. Any lead?

@ergun-p
Copy link

ergun-p commented Nov 8, 2018

Having the same issue. Any updates on this?

@CeccoCQ
Copy link

CeccoCQ commented Nov 8, 2018

Same issue here.

@ghost
Copy link

ghost commented Nov 9, 2018

Having this issues after updated Android studio 3.3-beta03

@ViHtarb
Copy link

ViHtarb commented Nov 9, 2018

Have same issue after migrating to 3.4 canary 3 android studio version. please fix it faster :)

@avcwisesa
Copy link

I'm also having the same issue.

@ghost
Copy link

ghost commented Nov 10, 2018

You can use the SNAPSHOT version to use.

@ViHtarb
Copy link

ViHtarb commented Nov 10, 2018

@kimcy929

You can use the SNAPSHOT version to use.

JakeWharton commented 11 days ago
Please test the SNAPSHOT build in about 20m. If this doesn't work I'm going to revert and ask you to file a jetifier bug.

j-ns commented 10 days ago
What's the version, 9.0.0-SNAPSHOT?

JakeWharton commented 10 days ago
Yep

j-ns commented 10 days ago •
Doesn't work. Still the same error message showing up.
I filed a bug in the google issue tracker

@ghost
Copy link

ghost commented Nov 10, 2018

When I used 9.0.0-SNAPSHOT, it worked again. 9.0.0-rc01 not work

@dogadaev
Copy link

Same issue.

@dogadaev
Copy link

dogadaev commented Nov 13, 2018

using 9.0.0-SNAPSHOT helped!

If you are getting "Failed to resolve" error then look here:
https://goo.gl/VcCT72

@JakeWharton
Copy link
Owner

See https://issuetracker.google.com/issues/118658603#comment5 for a workaround. No action to take on our side.

@primalbet
Copy link

See https://issuetracker.google.com/issues/118658603#comment5 for a workaround. No action to take on our side.

why do i have to put this in every android studio project that i create now? its stupid.. and plus i keep getting a warning every time i compile that this is experimental and not stable. can butterknife solve this issue so we don't have to manually import that in gradle.properties file?

@JakeWharton
Copy link
Owner

JakeWharton commented Feb 11, 2019 via email

@primalbet
Copy link

It's not needed with 10.0.0. The issue was with jetifier not this library.

On Mon, Feb 11, 2019 at 11:11 AM primalbet @.***> wrote: See https://issuetracker.google.com/issues/118658603#comment5 for a workaround. No action to take on our side. why do i have to put this in every android studio project that i create now? its stupid.. and plus i keep getting a warning every time i compile that this is experimental and not stable. can butterknife solve this issue so we don't have to manually import that in gradle.properties file? — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#1395 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEUF5qF54ZqqaymKffo6R6lfMQswCks5vMZY1gaJpZM4YCxUF .

thanks for the quick reply. i've been using 9.0.0-rc3 version, just noticed there is 10.0.0 which solves this problem

@wangqingpeng131
Copy link

When I used GlideApp, everything was fine, but when I switched to AndroidX, I compiled the error.

/app/build/generated/source/apt/debug/com/posttag/createbyai/GlideOptions.java:6: 错误: 程序包android.support.annotation不存在import android.support.annotation.CheckResult;

I tried to modify it.
implementation("com.github.bumptech.glide:glide:4.9.0") {
exclude group: "com.android.support"
}
But it doesn't work.

@h-amg
Copy link

h-amg commented Jun 25, 2019

I experienced the same problem after migrating to androidx. upgrade to the lest version of butterknife follow the library implementation instructions here. it'll work fine afterwords aside from some warning that has to do with am api going obsolete by the end of 2019

@denniswon
Copy link

denniswon commented Jul 3, 2019

Same issue here. After upgrading to AndroidX:

error: cannot find symbol
      @NonNull Registry registry) {
       ^
  symbol:   class NonNull
  location: class GeneratedAppGlideModuleImpl

Does anyone know how to make the glide compiler to use 'androidx.annotation' for generating app glide module instead of 'android.support.annotation'?

in app.gradle:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId 'com.leia.android.holochat'
        minSdkVersion 27
        targetSdkVersion 28
        versionCode getVersionCode()
        versionName getVersionName()
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        ndk {
            abiFilter 'arm64-v8a'
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            ext.enableCrashlytics = false
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        // We have multiple library dependencies that include this. Pick only one of them.
        pickFirst 'lib/arm64-v8a/libc++_shared.so'

        // There is an issue during the debug stripping step of libsnpe.
        // This workaround is from https://developer.qualcomm.com/comment/13293.
        doNotStrip "*/armeabi-v7a/libsnpe_*.so"
        doNotStrip "*/arm64-v8a/libsnpe_*.so"
    }

    productFlavors {
    }
}

...

dependencies {
    ...

    // Android support libraries
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

    implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    
    ....
    
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    ...

}

apply plugin: 'com.google.gms.google-services'

in gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

in proguard-rules.pro:


# Keep classes and class members annotated by the @Keep annotation.
# @Keep specifies not to shrink, optimize, or obfuscate the annotated class
# or class member as an entry point.

-keep @androidx.annotation.Keep class *

-keepclassmembers class * {
    @androidx.annotation.Keep *;
}

# Ignore warnings from third party libraries.
-dontwarn com.**
-dontwarn net.**
-dontwarn org.**
-dontwarn android.net.**

# For now, we're not obfuscating, because that can get confusing.
# https://stackoverflow.com/questions/9651703/using-proguard-with-android-without-obfuscation
-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable

-optimizationpasses 5

-dontwarn okhttp3.**
# https://www.guardsquare.com/en/products/proguard/manual/troubleshooting#unresolvedclass
-keep,includedescriptorclasses class *
# https://github.com/google/dagger/issues/645
-dontwarn dagger.releasablereferences.*

cc: @wangqingpeng131 seems very similar to the issue you posted. Have you resolved this?

@vaishaliidnani
Copy link

After updating Android Studio my project not running
1

pls any suggestion
my app. gradle is like this
buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
maven {
url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.code.ksoap2-android:ksoap2-android:3.1.1'
classpath 'io.fabric.tools:gradle:1.29.0'
}
}

repositories {
mavenCentral()
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }

}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

//apply plugin: 'com.neenbedankt.android-apt'
//apply plugin: 'com.github.dcendents.android-maven'
/def AAVersion = '4.5.2'/
def AAVersion = '4.6.0'
dependencies {
apply plugin: 'announce'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
}

android {
compileSdkVersion 28
buildToolsVersion '29.0.0'
dexOptions {
// incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}

defaultConfig {
    applicationId "com.system2.solutions.healthpotli.activities"
    minSdkVersion 23
    targetSdkVersion 28
    versionCode 100
    versionName "4.3.7"
    multiDexEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

bundle {
    language {
        enableSplit = true
    }
    density {
        enableSplit = true
    }
    abi {
        enableSplit = true
    }
}
lintOptions {

    checkReleaseBuilds false

}

}

/*
apt {
arguments {
resourcePackageName android.defaultConfig.applicationId
androidManifestFile variant.outputs[0]?.processResources?.manifestFile

}

}
*/

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

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13-beta-3'

//Youtube API
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'androidx.multidex:multidex:2.0.1'



//Smooth Custom Floating Action Menu

//Animation Library

//Font Awesome for Badge Count Update and Menu Item Icon

//SUB-DEPENDENCIES

//Android-Iconics - used to provide an easy API for icons

//KSoap For Webservice Call
implementation('com.facebook.android:facebook-android-sdk:5.1.1') {
    exclude group: 'com.android.support', module: 'multidex'
}

//Circle Image View

//Horizontal ListView

//Used For Easy Loading RecyclerView
implementation 'com.google.zxing:core:3.4.0'
implementation 'com.journeyapps:zxing-android-legacy:2.0.1@aar'
implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'

//compile 'com.android.support:recyclerview-v7:27.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'

//implementation 'com.android.support:recyclerview-v7:27.0.2'

// compile 'com.android.support:recyclerview-v7:26.1.0'
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'

// implementation 'com.google.android.gms:play-services-appindexing:9.0.2'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

/*compile 'com.google.android.gms:play-services-analytics:10.0.1'*/
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.mikepenz:actionitembadge:3.3.2@aar'
implementation 'com.mikepenz:iconics-core:4.0.1-b01@aar'
implementation 'com.google.code.ksoap2-android:ksoap2-android:3.1.1'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'it.sephiroth.android.library.horizontallistview:hlistview:1.3.1'
implementation 'com.jcodecraeer:xrecyclerview:1.2.7'
implementation 'com.daimajia.slider:library:1.1.5@aar'
implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
implementation 'com.wdullaer:materialdatetimepicker:4.2.1'
implementation 'com.bignerdranch.android:recyclerview-multiselect:0.2'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.thoughtbot:expandablerecyclerview:1.3'
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'net.gotev:uploadservice:3.3'
//compile 'com.github.rubensousa:gravitysnaphelper:1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
implementation('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
    exclude module: 'support-v4'
}
implementation('com.crashlytics.sdk.android:answers:1.4.1@aar') {
    transitive = true;
}

}

apply plugin: 'com.google.gms.google-services'

dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

dependencies {
implementation 'com.google.android.libraries.places:places:1.1.0'

}

@cobra0901
Copy link

Cannot find a version of 'androidx.appcompat:appcompat' that satisfies the version constraints:
Dependency path 'QumraApp:react-native-google-places:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' because of the following reason: ENABLE_JETIFIER is enabled
Constraint path 'QumraApp:react-native-google-places:unspecified' --> 'androidx.appcompat:appcompat:{strictly 1.0.0}' because of the following reason: releaseRuntimeClasspath uses version 1.0.0
Dependency path 'QumraApp:react-native-google-places:unspecified' --> 'com.facebook.react:react-native:0.60.4' --> 'androidx.appcompat:appcompat:1.0.2'
Dependency path 'QumraApp:react-native-google-places:unspecified' --> 'com.google.android.libraries.places:places:1.1.0' --> 'androidx.appcompat:appcompat:1.0.0'

@h-amg
Copy link

h-amg commented Jul 24, 2019

@denniswon have you tried migrating to androidx using android studio migration tool?

@vaishaliidnani from the screenshot you posted i think your project is running fine. these are just warning messages about an api that's going to be deprecated soon and you can ignore it. you should be able to run your app with android studio emulator or on your phone without any problems

UweTrottmann added a commit to UweTrottmann/SeriesGuide that referenced this issue Jan 8, 2020
@monika2104yadav
Copy link

I am having the same issue after migrating to androidx. If I upgrade butterknife to 10.2.0 then it asks to upgrade gradle to 4.10.0 after which there are other errors for which there is a need to downgrade gradle and hence butterknife. The issue "Failed to resolve androidX" is not going anyway. Here is my build.gradle file
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'com.google.gms.google-services' //Google Services plugin

android {
lintOptions {
checkReleaseBuilds false
}
compileSdkVersion 28
flavorDimensions "default"
defaultConfig {
applicationId "com.imbibeTodaySudokuAgain2104.wynud7.sudoku"
//minSdkVersion 15
//TODO: made it to 16 to enable firebase messaging
minSdkVersion 16
//TODO: recently occuring crashes after google play publication leading to crashes.
targetSdkVersion 28
//targetSdkVersion 36
versionCode 10
versionName "10"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
//lintOptions {
// checkReleaseBuilds false
//Or, if you prefer, you can continue to check for errors in release builds,
//but continue the build even when errors are found:
//abortOnError false
//}
}
buildTypes {
release {
minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/raw'] } }
}

dependencies {

//implementation 'com.android.support.multidex:1.0.2'
//implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
kapt 'com.jakewharton:butterknife-compiler:9.0.0-rc2'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'com.google.android.gms:play-services-ads:17.2.1'

//implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "androidx.lifecycle:lifecycle-*:2.3.0-alpha01"
//implementation "androidx.lifecycle:lifecycle:2.3.0-alpha01"
//implementation "android.arch.lifecycle:viewmodel:1.1.1"
//implementation "androidx.lifecycle.lifecycle-viewmodel:2.3.0"
//implementation group: 'androidx.lifecycle', name: 'lifecycle-extensions', version: '2.0.0-alpha1'

implementation "com.google.code.gson:gson:2.8.6"
//TODO:Note : the below three lines commented out is just because of the line below for magnetic press.
//implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"
//implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "androidx.appcompat:appcompat:1.1.0"

//implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
//implementation 'com.android.support:design:28.0.0'
implementation "com.google.android.material:material:1.0.0"

testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.2'

// androidTestImplementation 'androidx.test:runner:1.1.0'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation "androidx.test:rules:1.1.0"

androidTestImplementation "androidx.test:runner:1.2.0-alpha03"
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0-alpha03"
//androidTestImplementation "androidx.test.espresso:espresso-core:3.1.0"

implementation 'com.github.hotchemi:android-rate:1.0.1'

//implementation 'com.android.billingclient:billing:1.1'

//implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-database:19.2.1'
implementation 'com.google.firebase:firebase-analytics:17.3.0'

}

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