Tencent / tinker

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Other
17.14k stars 3.33k forks source link

class file for android.support.annotation.Keep not found #1359

Open o0starshine0o opened 4 years ago

o0starshine0o commented 4 years ago

异常类型:编译异常

tinker版本:1.9.14.5

gradle版本:3.5.3(插件版本)Gradle version:6.1.1

classpath 'com.android.tools.build:gradle:3.5.3' distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

是否使用热更新SDK: TinkerPatch SDK

系统:如:Mac

使用DEMO工程,再把issue1343解决掉之后,又面临了这个问题,搜索了一遍之后发现应该是com.tencent.tinker:tinker-android-anno:1.9.14.5这个注解处理库没有按照更新的要求写,这里记录下这个问题,帮助其他朋友。

以下是完整的报错信息

4:09:46 PM: Executing task 'assembleDebug'...

Executing tasks: [assembleDebug] in project /Users/admin/Desktop/Android/tinker/tinker-sample-android/app

> Configure project :app
reflectDexArchiveFlag error: ENABLE_DEX_ARCHIVE.
----------------------tinker build warning ------------------------------------
tinker auto operation: 
excluding annotation processor and source template from app packaging. Enable dx jumboMode to reduce package size.
enable dx jumboMode to reduce package size.
disable preDexLibraries to prevent ClassDefNotFoundException when your app is booting.
disable archive dex mode so far for keeping dex apply.

tinker will change your build configs:
we will add TINKER_ID=a8b2941 in your build output manifest file build/intermediates/manifests/full/*

if minifyEnabled is true
you will find the gen proguard rule file at build/intermediates/tinker_intermediates/tinker_proguard.pro
and we will help you to put it in the proguardFiles.

if multiDexEnabled is true
you will find the gen multiDexKeepProguard file at build/intermediates/tinker_intermediates/tinker_multidexkeep.pro
and we will help you to put it in the MultiDexKeepProguardFile.

if applyResourceMapping file is exist
we will build app apk with resource R.txt file
if resources.arsc has changed, you should use applyResource mode to build the new apk!
-----------------------------------------------------------------
R8Transform original mainDexRulesFiles: [/Users/admin/Desktop/Android/tinker/tinker-sample-android/app/tinker_multidexkeep.pro]
R8Transform replaced mainDexRulesFiles: [/Users/admin/Desktop/Android/tinker/tinker-sample-android/app/tinker_multidexkeep.pro, /Users/admin/Desktop/Android/tinker/tinker-sample-android/app/build/intermediates/legacy_multidex_aapt_derived_proguard_rules/release/processReleaseResources/manifest_keep.txt]

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest

> Task :app:tinkerProcessDebugManifest
tinker add tinker_id_a8b2941 to your AndroidManifest.xml /Users/admin/Desktop/Android/tinker/tinker-sample-android/app/build/intermediates/merged_manifests/debug/AndroidManifest.xml
tinker add tinker.sample.android.app.SampleApplication to dex loader pattern
tinker add com.tencent.tinker.loader.* to dex loader pattern
tinker gen AndroidManifest.xml in build/intermediates/tinker_intermediates/AndroidManifest.xml

> Task :app:tinkerProcessDebugResourceId
apply resource mapping file /Users/admin/Desktop/Android/tinker/tinker-sample-android/app/build/bakApk/app-debug-0424-15-02-56-R.txt is illegal, just ignore

> Task :app:processDebugResources UP-TO-DATE

> Task :app:compileDebugJavaWithJavac FAILED
Gradle may disable incremental compilation as the following annotation processors are not incremental: tinker-android-anno-1.9.14.5.jar (com.tencent.tinker:tinker-android-anno:1.9.14.5).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
error: cannot access Keep
  class file for android.support.annotation.Keep not found
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
12 actionable tasks: 4 executed, 8 up-to-date
4:09:48 PM: Task execution finished 'assembleDebug'.
LeaYw commented 4 years ago

我也遇到了这个问题,在根目录下的gradle.properties里边加上android.enableJetifier=true就可以了

chenxukunyx commented 4 years ago

正解,测试可用

YaowenGuo commented 3 years ago

我也遇到了这个问题,在根目录下的gradle.properties里边加上android.enableJetifier=true就可以了

Tinker 1.9.14.9 我设置了 android.enableJetifier=true 还是会有这个问题呀。

Kirito0512 commented 3 years ago

TINKER_VERSION=1.9.14.5 加上android.enableJetifier=true后可以了