我在我的一个项目中使用了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>
型
ERROR:
- 执行任务':app:compileDebugJavaWithJavac'失败。**>超类访问检查失败:类butterknife.compiler.ButterKnifeProcessor$RScanner(在未命名模块@0x67c173dd中)无法访问类com.sun.tools.javac.tree.TreeScanner(在模块jdk.compiler中),因为模块jdk.compiler不会将com.sun.tools.javac.tree导出到未命名模块@0x67c173dd*
尝试更新,重建项目,但它没有帮助,请我不能重写整个项目**删除butterknife依赖。
2条答案
按热度按时间d4so4syb1#
你没有太多的选择,因为为了继续使用ButterKnife,你必须降级到旧版本的gradle(3.+),这不再是可能的,会限制你太多。
gmxoilav2#
请在build.gradle(:app)文件中添加这一行。
android {tasks. with Type(JavaCompile). configureEach {options. fork = true选项。forkOptions. jvmArgs +=['--add-openes = jdk。compiler/com.太阳工具javac。tree = ALL-UNNAMED','--add-openes = jdk。compiler/com.太阳工具javac。code = ALL-UNNAMED','--add-openes = jdk. compiler/com.太阳工具javac。comp = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。file = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。main = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。model = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。parser = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。processing = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。util = ALL-UNNAMED','--add-opens = jdk. compiler/com.太阳工具javac。jvm = ALL-UNNAMED',]}}