error: package android.support.annotation does not exist
The imports inside the auto generated _ViewBinding.java is
import android.support.annotation.CallSuper;
but it should be
import androidx.annotation.annotation.CallSuper;
This is an Android tools bug and not a Butter Knife bug. The dejetifier should rewrite the bytecode of the androidx library to the old android.support package so that this works. Ensure you have dejetifier enabled. Changing the library to generate references to jetpack libraries instead of support libraries is another feature request.
How do you enable dejetifier in Android Studio 3.2 canary? The Refactor to AndroidX... menu command added these lines to gradle.properties:
android.enableJetifier=true
android.useAndroidX=true
Also, the issue is occurring for me in gradle modules besides my app module. I don't know if that makes any difference.
Android studio did add these 2 lines for me. Did not work.
Butter Knife generates code that is not AndroidX and therefore you should not have useAndroidX set to true.
Note that you can't use jetifier without enabling androidx, otherwise build fails with this warning:
AndroidX must be enabled when Jetifier is enabled. To resolve, set android.useAndroidX=true in your gradle.properties file.
So, until now, there is no way to use Butter Knife + AndroidX?
I was planning to adopt the new Material Theme and components.
You can add your own copies of the support library annotations in the old
namespace as a temporary workaround
On 5/12/18 at 8:21 PM, Rafael wrote:
So, until now, there is no way to use Butter Knife + AndroidX?
I was planning to adopt the new Material Theme and components.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1270#issuecomment-388598160,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABTEvmBEAAIIc3OfuNa38qwK9JdyDZTbks5tx6a8gaJpZM4T3eOP
.
@rtchagas you can try using Android Support Design 28 for Material components for now.
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
@k4dima this does not work will all scenarios like when using a view pager. You will then get this error
error: package android.support.v4.view does not exist
09:51:42.280 [ERROR] [system.err] import android.support.v4.view.ViewPager;
I'm using many view pagers and the @k4dima solution worked fine.
Maybe something with your project? I had to change all support view pagers
to androidx equivalents.
On Tue, Jul 10, 2018, 10:54 PM dri94 notifications@github.com wrote:
@k4dima https://github.com/k4dima this does not work will all scenarios
like when using a view pager. You will then get this error
error: package android.support.v4.view does not exist 09:51:42.280 [ERROR]
[system.err] import android.support.v4.view.ViewPager;—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1270#issuecomment-403830493,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABu3qdIVBqeEqg48trTvumdkBBr3k_X0ks5uFLIygaJpZM4T3eOP
.
@rtchagas are you sure you are using onPageChange. As even in the onPageChange.java file in ButterKnife it is still using import android.support.annotation.IdRes; instead of import androidx.annotation.IdRes;
@k4dima Are you able to make it work for library modules as well?
@JakeWharton
Ensure you have dejetifier enabled.
How can one enable dejetifier? Is it enabled in gradle.properties?
Haven't found any related info
problem occurred configuring project ':app'.
AndroidX must be enabled when Jetifier is enabled. To resolve, set android.useAndroidX=true in your gradle.properties file.
not solve the problem
Most helpful comment