I am not able to build android project due to error of butterknife dependency.
ERROR
Execution failed for task ':app:javaPreCompileDebug'.
Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.
Failed to transform butterknife-compiler-8.6.0.jar (com.jakewharton:butterknife-compiler:8.6.0) to match attributes
{artifactType=processed-jar, org.gradle.category=library,
org.gradle.libraryelements=jar, org.gradle.status=release,
org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: /Users/jordan/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.6.0/d3defb48a63aa0591117d0cec09f47a13fffda19/butterknife-compiler-8.6.0.jar.
> Failed to transform '/Users/jordan/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.6.0/d3defb48a63aa0591117d0cec09f47a13fffda19/butterknife-compiler-8.6.0.jar'
using Jetifier. Reason: AmbiguousStringJetifierException, message: 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.. (Run with --stacktrace
for more details.)
This is a known exception, and Jetifier won't be able to jetify this library.
Suggestions:
- If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support
libraries/AndroidX at all), add android.jetifier.blacklist =
{comma-separated list of regular expressions (or simply names) of the
libraries that you don't want to be jetified} to the gradle.properties
file.
- If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't
jetified), contact the library's authors to update this library to
support AndroidX and use the supported version once it is released.
If you need further help, please leave a comment at
Dependency in Gradle Build File in App Level
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta02'
implementation 'com.melnykov:floatingactionbutton:1.3.0'
// implementation 'com.android.support:design:28.0.0'
// implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.jpardogo.materialtabstrip:library:1.0.6'
implementation 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}
how should I resolve it ?
Please note that, as per official documentation the Butter Knife tool is now deprecated.
And they have recommended to switch to View Binding.
Hence, I request you to revisit your decision of using Butter Knife.
And in your gradle files, please ensure that below lines are added properly.
Add these changes and then click on File > Invalidate Cache and Restart in Android Studio.
android {
...
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Dependency
dependencies {
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
}
If you are using Kotlin, replace annotationProcessor with kapt.
And to use Butter Knife in a library, please follow the steps provided in section Library Projects inside official documentation
Related
I cannot build my project due to it failing because it cannot find a class. Is there something wrong with my sdk or dependancies?
I have tried invalidating cache and restarting. I am using api 29.
The following is where the error shows up
public class PodcastUpdateWorker extends Worker {
}
Here is the error printout
/home/snowman/AndroidStudioProjects/CorbettReportPodcasts/app/src/main/java/com/example/corbettreportpodcasts/PodcastUpdateWorker.java:36: error: cannot access ListenableFuture
public class PodcastUpdateWorker extends Worker {
^
class file for com.google.common.util.concurrent.ListenableFuture not found
and my dependancies
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
testImplementation "androidx.room:room-testing:2.2.5"
implementation 'androidx.work:work-runtime:2.4.0'
implementation 'com.google.android.material:material:1.2.1'
}
any help is appreciated
There is an issue with the exoplayer library conflicting with listenablefuture causing it not to be found. READ MORE
you can include guava implementation 'com.google.guava:guava:29.0-android' to fix this
implementation "androidx.concurrent:concurrent-futures:1.1.0"
Reference: https://developer.android.com/jetpack/androidx/releases/concurrent
Check for the package name in gradle scripts (module:app) and in ...app>src>main>java.
Rename the folder to the desired package name. Make sure that the package name is changed in all the java files also. After renaming, sync your project with gradle files.
If you are doing this after the first Gradle sync, then this trick may not work. You need to change them manually.
I solved it by updating
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
to
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
also update these to latest versions, if applicable
api 'androidx.core:core-ktx:1.3.2'
api "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"
In addition to the accepted answer. I didn't user Exoplayer in the application. After digging deeper I found that if you use Google's library for guava to fix conflicts like this:
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
This will also cause an issue. Removing this dependency solved the problem. BUT on the other hand, if you use some library, which causes the problem with listenablefeature in opposite adding this dependency solves the problem.
I just had to move my android application to androidx because of several problems. Now I have the problem, that the App is "greyed out" in the Desginer (See Screenshot):
Screenshot
In the designer there is a error message:
The following classes could not be found:
- android.support.constraint.ConstraintLayout ( Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class)
I would assume there is a missing class for the constraint Layout, but that is not the case. That is my build.gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
}
Do you have any idea?
I already tried everything on the internet, make app, rebuild, sync with gradle files, trying different versions of the constraint layout.
Looks like you are trying to use AndroidX libraries and Support libraries in same project. Migrate to AndroidX from menu, it will replace package names and dependencies.
Your project is adding widgets from Support libraries instead of AndroidX which is causing this issue.
If you still get errors, replace old package names from the ones in the list: https://developer.android.com/jetpack/androidx/migrate
Looks like you are trying to use android.support.constraint.ConstraintLayout while adding a dependency to androidx.constraintlayout:constraintlayout. Just use the latter in your XML.
try adding the material design dependency
implementation 'com.google.android.material:material:1.1.0'
your appcompat should also be:
implementation 'androidx.appcompat:appcompat:1.1.0'
you are using androidx constaint layout dependency but your other dependencies aren't compatible
I'm trying to make an app that uses google maps API.
But there seems to be an error in regards to libraries, that are incompatible.
It says
'Found versions 28.0.0 and 26.1.0 examples including
com.android.support:animated_vector_drawable:28.0.0 and
com.android.support:support-media-compact:26.1.0
Would this have an effect on calling R.id by any chance?
I've tried clean and rebuild, and invalid cache reset.
I tried to add the files as version 28.0.0 in dependency and received 2 errors:
Failed to resolve: com.android.support:support-media-compact:28.0.0
Failed to resolve: com.android
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compact:28.0.0'
implementation 'com.android.support:animated_vector_drawable:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I would've thought that rewriting the versions would have fixed the problem but 'com.android.support:appcompat-v7:28.0.0' is still underlined in red.
Using the Gradle View plugin http://plugins.jetbrains.com/plugin/7150-gradle-view, I determined the issue is that play-services-location:16.0.0 has a dependency on com.android.support:support-media-compat:26.1.0. One technique I found to remove the warning is described here: https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html
which led me to add this to my gradle file:
implementation("com.android.support:appcompat-v7:28.0.0") {
force = true
}
Here you can see the latest libraries update available : link to go . And if you face again an error, you have to post the Logcat.
Add all the dependencies (that is said to be conflicting with existing libraries) with same version no. of which it is conflicting with.
I'm trying to develop a location map for uni. The app itself works on my phone but I can't edit the XML file or preview it
I've already enabled virtualisation and have an i5 processor. I believe the issue lies in the Gradle build but don't know how to fix it.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
And the error message:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
Inspection info: There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
It looks like the media-compat:26 should be updated to a newer version but I can't find the code for it or the library and don't know how to download the library. Any help will be appreciated.
You need to set your compileSdkVersion and targetSdkVersion to 28. Because all your support libraries must match to your compileSdkVersion's root number. And, if you add more support libraries like- support:design or support:recyclerview-v7, you must add the same version (here you used 28.0.0). Otherwise, the app can crash at the runtime for mismatching. The full Google repository for android is here http://maven.google.com.
To know more about gradle dependencies of android, please go to official documentation here. For google play service API configuration, go to this link.
Try change implementation 'com.android.support:appcompat-v7:28.0.0' to:
implementation 'com.android.support:appcompat-v7:26.1.0'
compileSdkVersion 26
targetSdkVersion 26
All libraries must have the same version, in the case it looks like a conflict between com.google.android.gms: play-services-maps: 16.0.0 and implementation 'com.android.support: appcompat-v7:28.0.0'.
If you are using compileSdkVersion 28 try to find the latest version of the libraries in the maven repository.
https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0
As you can see, i think all the support libraries have same version then why this error?
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
I think there may be 2 reasons:
1) When you hover over the error it will probably tell you which library has the wrong version, and maybe it's not even present in your dependencies, but probably one of your libraries is internally using it, so you need to specify them separately with the same version.
2) Or it may be due to the fact that one of the libraries (it's probably firebase) is compiled against a different version of the support library and that's causing the conflict. So you need your support libraries to match the support library that firebase is compiled against. For example look at how Glide explains it here:
Support Library Version - Glide uses support library version 27.
If you need or would prefer to use a different version of the support library you should exclude "com.android.support" from your Glide dependency in your build.gradle file.
So to check, if you delete the firebase dependency it will probably build. If that's the case, then you need to check against which version your version of firebase is compiled and use that.