ButterKnife not working with Jack? - android

I just started a very simple project and tried to use both ButterKnife and Jack compiler, but it seems they do not cope with each other well.
Gradle plugin version: 2.2.0-alpha5
in my module build.gradle I added:
compile 'com.jakewharton:butterknife:8.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1'
And the error message is:
Error:Execution failed for task ':app:transformJackWithJackForDebug'.
java.lang.AssertionError: java.lang.IllegalArgumentException
Did I miss something or it's just they are not compatible?

Version 8.3.0 has just recently been released with support for Jack.
compile 'com.jakewharton:butterknife:8.3.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.3.0'

Try remove apply plugin: 'android-apt' in your app gradle.
As in the readme, it says:
Note: If you are using the new Jack compiler with version 2.2.0 or newer you do not need the 'android-apt' plugin and can instead replace apt with annotationProcessor when declaring the compiler dependency.

Thanks to #isnotmenow 's tip, I tried to change ButterKnife version to 8.1.0 and it works well.
But both 8.2.0 and 8.2.1 complain exceptions, I have post an an issue on the project page.

Here's a Jake Wharton's answer from similar StackOverflow post:
If you are using Jack:
Omit the 'android-apt' plugin completely.
Use annotationProcessor for the dependency (instead of apt).
I believe you have to be using version 2.2.0 of the Android Gradle
plugin though instead of 2.1.x (currently the latest is 2.2.0-alpha5).
The Butter Knife documentation will be updated for the next release
(8.2.0) to include this information.
From: Butterknife 8.1.0 not working with JDK 1.8 in Android Studio 2.1.2
Check also: http://github.com/JakeWharton/butterknife/issues/616
Hope it will help

Related

Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'

I'm having a problem with running my android app:
Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
That is caused by 1.7.0:
implementation 'com.google.android.material:material:1.7.0'
You better stick to 1.6.0 till they fix this
implementation 'com.google.android.material:material:1.6.0'
In your build.gradle file where "dependencies" section is paste this:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
in this section. And remove old strings with same text and other number versions. (in my case:
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
). Have worked for me.
source: https://github.com/facebook/react-native/issues/33926
Upgraded android gradle plugin to 7.2.2 and the problem is solved. Try updating Android Studio too
Rationale
To expand on the existing answers, the release notes for Material Components for Android 1.7.0 mentions that they have updated the minimum requirements for your project (emphasis mine):
New minimum requirements for your app's project:
Update to Android Gradle Plugin (AGP) version 7.2.0
Update to Gradle version 7.3.3
Update to Java 8 (version 1.8)
Update to Android Studio Chipmunk, version 2021.2.1
This is also mentioned in their (updated) Getting Started guide (again, emphasis mine):
5. Gradle, AGP, and Android Studio
When using MDC-Android version 1.7.0-alpha02 and above, you will need to make sure your project is built with the following minimum requirements, in order to support the latest build features such as XML macro:
Gradle version 7.3.3
Android Gradle Plugin (AGP) version 7.2.0
Android Studio Chipmunk, version 2021.2.1
Updating the Android Gradle Plugin
You can update the Android Gradle plugin as follows:
Gradle plugins DSL
The plugin declaration can be found in the top-level build.gradle/build.gradle.kts file:
plugins {
// Or "com.android.library"
id("com.android.application") version "7.2.2" apply false
}
Buildscript classpath
Update the AGP classpath dependency (usually in the top-level build.gradle/build.gradle.kts file):
classpath("com.android.tools.build:gradle:7.2.2")
update your build.gradle file as below:
classpath 'com.android.tools.build:gradle:7.2.1'
It will fix the issues, remember v7.3.x wont fix the issue, so stick to 7.2.1 as of now.
For Flutter User with this issue this is how you solve it::
Goto : build.gradle
change "classpath 'com.andriod.tools.build:gradle:5.6.0'"
to
"classpath 'com.andriod.tools.build:gradle:<latest version>'"
in my case :: classpath 'com.android.tools.build:gradle:7.2.1'
then goto :: android/gradle/wrapper/gradle-wrapper.properties
then change
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.3-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-<latest>-all.zip
in my case distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
In build.gradle(:app),
Updating, compileSdk and targetSdk to 33 helped me(from 32).
In order to get over with this. Upgrade to the latest gradle version as well as latest Android Studio.
I was also facing this issue and I followed these steps :
Upgraded Android Studio to Android Studio Dolphin | 2021.3.1 Patch 1
gradle version to 7.3.1 in project build.gradle
kotlin version to 1.7.20 in project build.gradle
targetSdkVersion and compileSdkVersion to 33
latest version of dependencies in app's build.gradle
And the project is perfectly working fine now.
I resolved it by replacing implementation 'androidx.recyclerview:recyclerview:1.2.1' instead of implementation 'com.google.android.material:material:1.7.0' in build.gradle(:app)
Upgraded android gradle plugin >= 7.1.0 and the problem is solved.
classpath "com.android.tools.build:gradle:7.1.0"
After wasting 2 hours and ruining my mood solution was simply upgrading your android studio version, most probably you are using an older version like Arctic fox or something like that, upgrade to dolphin or something higher. Hope it help, and yes in dolphin version it will give error of 30.0.3 but don't worry it gives you an attached link to install 30.0.0 SDK in console itself, so chill and keep developing.
first, in the gradle build file, change the implementation from 1.7.0 to 1.6.0
Next, open the colors file and change the color of the tag (#) which has 7 digits to a 6 digit tag. Because usually the default color of tags on Android Studio is sometimes 7 digits or 6 digits
I solved this by :
Adding in build.gradle:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
adding android:exported="true" in Manifest

Errrors, when configuring react-native project (building gradle) with android studio. I want to build gradle scripts for using firebase with my app

I ran into this problem after i updated android studio and the gradle version. Here's what i did step by step:
First i got the following error:
Build Gradle Error Could not get unknown property 'compile'
I checked stackoverflow and it said that changing "compile" with "implementation" would solve the problem, and so i did that.
Another issue was that maven was deprecated. So i used, maven-publish instead of maven.
Now i am getting the following error:
12:24 PM Gradle sync failed: Could not find method uploadArchives() for arguments [build_a5ye7ixpcm9qfmol93kt3ucl1$_run_closure4#73b8042a] on project ':expo-application' of type org.gradle.api.Project. (17 s 537 ms)
In this part of code in build.gradle(:expo-application):
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: mavenLocal().url)
}
}
}
I am not really familiar with android studio or java. I just use Android Studio for configuring react native apps for android. Can someone please help me resolve these issues..
Thank you
As of Gradle 7.0, compile has been removed in favor of api. When you changed compile to implementation, you effected the transitive properties of the libraries. I'm not sure where you read that changing compile to implementation was the correct answer, but it isn't. api is a much closer approximation to compile. This chart gives a fairly easy to understand explanation of why this is. You should change the implementation to api and make sure you are using the java-library plugin instead of the java plugin. This should allow gradle to see the UploadArchives method. However, this wil cause a new issue.
As of Gradle 6.0, UploadArchives is also deprecated along with the maven plugin. You should consider using the maven-publish plugin instead. This will ensure your build continues to work in future Gradle releases.
So, to summarize, make sure your plugins look like this
apply plugin: 'java-library'
apply plugin: 'maven-publish'
and update your code to use publishing instead of UploadArchives. More information on this can be found in the current Gradle user guide here.
Alternatively, you can downgrade your gradle version to something before 7.0 and just ignore all the deprecation warnings. The choice is yours.

API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'

When building gradle I'm getting this message:
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'
I'm using Android Studio 4.1 Canary 10 and gradle:4.1.0-alpha10
It seems like the Navigation Safe Args plugin uses getApplicationIdTextResource(), so it is most likely that the error message is caused by your usage of that plugin.
You'd want to star the existing issue to ask the Safe Args plugin to use the new replacement API.
Changing to androidx.navigation:navigation-*:2.4.0-alpha02 as described here allowed a build of my app under Arctic Fox without getting the getApplicationIdTestResource warning
From the application build.gradle file:
def nav_version = "2.4.0-alpha02"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
And in the build.gradle file:
def nav_version = "2.4.0-alpha02"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
few days i see the same issue. Then i go to ->
build.gradle file
My Dependencies before update
check the dependencies
I update the dependencies google services to 4.3.4
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
After update
Now its working fine.
This error was for NavigationComponent for me in Android Studio Cannery 13.
So I changed the nav_version to this and My issue was solved.
ext {
*************** nav_version = "2.4.0-alpha10" ************
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha13'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
and in app module build.gradle:
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
It will be solved, when 4.2.0 is stable.
From the existing issue:
Android Gradle Plugin deprecated the getApplicationIdTextResource()
API on the class BaseVariant in version 4.1.0 (see bug). The
replacement API (onVariantProperties) did not work properly for
feature libraries, so to avoid the deprecation warning, reflection was
used. That is only a short term solution, and when AGP 4.2.0 is stable
we should update to that version and remove the reflection immediately
So if you need Safe Args and do not need latest features of Gradle, keep Gradle version in Android Gradle Plugin version at 3.6.4. Once stable 4.2.0 released, update to the latest.
This error happened after i updated kotlin version to 1.7.
this was for NavigationComponent in Android Studio
So I changed the nav_version to this and My issue was solved : "2.4.0-beta02"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.4.0-beta02"
implementation "androidx.navigation:navigation-ui-ktx:2.4.0-beta02"
For me it was because of different Kotlin versions between IDE Kotlin plugin and project_name/build.gradle file
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
"Kotlin version that is used for building with Gradle (1.3.72) differs from the one bundled into the IDE plugin (1.4.31) "
Once I made it even it started to compile again.
In my case I was using 2.3.1 version of navigation-fragment.
I just updated it to 2.4.2 and it's helped me
So, What i have done is that I have upgraded all the gradle plugins as well as dependecies versions and then run, It worked for me
I had the same problem and it was solved like this:
So I go to -> build.gradle file
My dependencies before upgrade
check the dependencies
I update Google services dependencies to latest version
dependencies {
classpath 'com.android.tools.build:gradle:(latest version)'
classpath 'com.google.gms:google-services:(latest version)'
}
Android Studio 4.1 giving the following information and It will be removed in version 5.0 of Android Gradle Plugin.
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see TBD.
To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
As #ianhanniballake has pointed out, it seems likely that it's caused by the Navigation Safe Args plugin, see the existing issue, also referenced from his answer. The issue was marked as fixed on 9 November.
In terms of fixing the build error, upgrading Android Studio from 4.1.0 to 4.1.1 fixed it for me.
delete the .idea and .gradle files from the project .. it worked with me

Update gradle version to 5.1.1, but kapt not work

It was all work fine in gradle version 4.5, but when I update to 5.1.1, the processor that extends AbstractProcessor seems did not was execute, not any log and nothing was generated in dir: build/generated/source/kapt.
gradle version: 4.5; gradle plugin: 3.1.2. work
gradle version: 5.1.1; gradle plugin: 3.4.1. not work
PS: see git https://github.com/drumge/android-kvo
I had this same problem on upgrade of Android Studio (3.3 -> 3.4) (This upgrades gradle from 4.10.1 -> 5.1.1).
I'm using kapt, and an annotation processor I built as a java module. Everything worked fine before the update.
My solution was:
- Upgrade com.google.auto.service:auto-service to 1.0-rc6
- Add annotationProcessor "com.google.auto.service:auto-service:1.0-rc6" to the annotation processor's build.gradle file.
Found my answer via these:
- https://github.com/gradle/gradle/issues/7941
- https://github.com/ishaigor/annotation-processor-sample/commit/d7645914b9f53a5f350c7098973f3554c48e75d8
Hope this helps.
In your build.graddle module app include this : apply plugin: 'kotlin-kapt'

Unresolved reference: Observable in Android Studio 3.4

Updated to Android Studio 3.4, with Gradle 5.1.1 and Kotlin 1.3.10 as minimum versions. Cannot run project anymore due to reactivex.Observable not being found. Has anyone found a solution?
Was using rxBinding lib, also tried using latest vesions RxJava 2.2.8 and RxAndroid 2.1.1 with no success.
Downgrading the build.gradle(project) from classpath 'com.android.tools.build:gradle:3.4.0' to classpath 'com.android.tools.build:gradle:3.2.1' might be help you
The issue is that you need to use RxJava 2.2.8 and if you check the RxAndroid gradle file they are using the RxJava version 2.2.6 :
https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle
If you force RxJava to use version 2.2.8 it will work.
Add to gradle:
implementation 'io.reactivex.rxjava2:rxjava:2.2.8
Yeah the workaround* for me was to downgrade from gradle 5.1.1 to 4.10.1 and also to the latest android gradle plugin prior to 3.4.0, which is 3.3.2.
I did this in gradle/wrapper/gradle-wrapper.properties by changing to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
I then also changed the following in my root build.gradle file:
'com.android.tools.build:gradle:3.4.0' to 'com.android.tools.build:gradle:3.3.2'
Along with the dependency of RxKotlin use this
api 'io.reactivex.rxjava2:rxjava:2.2.0'
Only works for Gradle 5.0 or above
The accepted answer ended up leading me to the solution: leaving the gradle-wrapper.properties intact and don't increase the gradle version at all. We'll see if a future lib update will solve it for gradle 3.4.

Categories

Resources