如何解决这个 Butterknife 依赖错误? (在未命名模块@0x67c173dd 中)
How to solve this Butterknife dependency error? (in unnamed module @0x67c173dd)
我在我的一个项目中使用 butterknife 作为我的依赖之一,虽然我知道它已被弃用,但重写整个代码将是一项巨大的工作。
build.gradle :
buildscript {
repositories {
maven {
url "https://jcenter.bintray.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AndroidManifest.xml :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="nikolairb.createpdf">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="scopedStorage"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppThemeWhite"
tools:ignore="GoogleAppIndexingWarning,RtlEnabled">
<activity android:name=".activity.SplashActivity" android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:exported="true"
android:theme="@style/Base.Theme.AppCompat" />
<activity
android:name=".activity.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name=".activity.CropImageActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.swati4star.shareFile"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<activity android:name=".activity.WelcomeActivity" android:exported="true"/>
<activity android:name=".activity.ImageEditor" android:exported="true" />
<activity android:name=".activity.PreviewActivity" android:exported="true" />
<activity android:name=".activity.RearrangeImages" android:exported="true" />
<activity android:name=".activity.ImagesPreviewActivity" android:exported="true"/>
<activity android:name=".activity.RearrangePdfPages" android:exported="true"/>
<activity android:name=".activity.FavouritesActivity" android:exported="true"/>
</application>
</manifest>
错误:
任务“:app:compileDebugJavaWithJavac”执行失败。
> superclass 访问检查失败:class butterknife.compiler.ButterKnifeProcessor$RScanner(在未命名模块 @0x67c173dd 中)无法访问 class com.sun.tools.javac.tree.TreeScanner(在模块中jdk.compiler) 因为模块 jdk.compiler 不会导出 com.sun.tools.javac.tree 到未命名的模块 @0x67c173dd
尝试更新、重建项目,但没有帮助,我无法重写整个项目删除 butterknife 依赖项。
您没有太多选择,因为要继续使用 ButterKnife,您必须降级到 gradle (3.+) 的旧版本,而这不再可行并且会限制您太多了。
我在我的一个项目中使用 butterknife 作为我的依赖之一,虽然我知道它已被弃用,但重写整个代码将是一项巨大的工作。
build.gradle :
buildscript {
repositories {
maven {
url "https://jcenter.bintray.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
AndroidManifest.xml :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="nikolairb.createpdf">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="scopedStorage"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppThemeWhite"
tools:ignore="GoogleAppIndexingWarning,RtlEnabled">
<activity android:name=".activity.SplashActivity" android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:exported="true"
android:theme="@style/Base.Theme.AppCompat" />
<activity
android:name=".activity.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name=".activity.CropImageActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.swati4star.shareFile"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<activity android:name=".activity.WelcomeActivity" android:exported="true"/>
<activity android:name=".activity.ImageEditor" android:exported="true" />
<activity android:name=".activity.PreviewActivity" android:exported="true" />
<activity android:name=".activity.RearrangeImages" android:exported="true" />
<activity android:name=".activity.ImagesPreviewActivity" android:exported="true"/>
<activity android:name=".activity.RearrangePdfPages" android:exported="true"/>
<activity android:name=".activity.FavouritesActivity" android:exported="true"/>
</application>
</manifest>
错误:
任务“:app:compileDebugJavaWithJavac”执行失败。 > superclass 访问检查失败:class butterknife.compiler.ButterKnifeProcessor$RScanner(在未命名模块 @0x67c173dd 中)无法访问 class com.sun.tools.javac.tree.TreeScanner(在模块中jdk.compiler) 因为模块 jdk.compiler 不会导出 com.sun.tools.javac.tree 到未命名的模块 @0x67c173dd
尝试更新、重建项目,但没有帮助,我无法重写整个项目删除 butterknife 依赖项。
您没有太多选择,因为要继续使用 ButterKnife,您必须降级到 gradle (3.+) 的旧版本,而这不再可行并且会限制您太多了。