MegatronKing / StringFog

一款自动对字节码中的字符串进行加密Android插件工具
Apache License 2.0
1.67k stars 334 forks source link

多渠道打包报错。 #8

Closed flyuuo9 closed 6 years ago

flyuuo9 commented 6 years ago

看了源码应该是用到applicationId作生成代码的路径,实际上不存在的路径。 只有manifest里面的package生成R时有个目录。但是和applicationId不一样。导致报错

public void createFogClass(DomainObjectSet<BaseVariant> variants) {
        variants.all { variant ->
            variant.outputs.forEach { output ->
                def processResources = output.processResources
                processResources.doLast {
                    def stringfogDir = variant.applicationId.replace((char)'.', (char)File.separatorChar)
                    def stringfogFile = new File(processResources.sourceOutputDir, stringfogDir + File.separator + "StringFog.java")
                    StringFogClassBuilder.buildStringFogClass(stringfogFile, processResources.sourceOutputDir,
                            variant.applicationId, "StringFog", mKey)
                }
            }
        }
    }

把两者改成一样出现另外一个错误,没显示具体哪个文件出错

:app:mergeXXXDebugAssets
:app:transformClassesWithStringFogForXXXDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithStringFogForXXXDebug'.
> Unexpected internal error near index 1
  \
   ^

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

BUILD FAILED

Total time: 13.547 secs
flyuuo9 commented 6 years ago

13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.util.regex.PatternSyntaxException: Unexpected i nternal error near index 1 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] \ 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] ^ 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.WhiteLists.s hortClassName(WhiteLists.java:114) 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.WhiteLists.i nWhiteList(WhiteLists.java:85) 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.ClassVisitor Factory.create(ClassVisitorFactory.java:39) 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.StringFogCla ssInjector.processClass(StringFogClassInjector.java:106) 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.StringFogCla ssInjector.doFog2Class(StringFogClassInjector.java:52) 13:46:51.454 [ERROR] [org.gradle.BuildExceptionReporter] at com.github.megatronking.stringfog.plugin.StringFogCla

flyuuo9 commented 6 years ago

https://stackoverflow.com/questions/34129054/patternsyntaxexception-unexpected-internal-error-near-index-1-for-splitfile windows下的分隔符问题

MegatronKing commented 6 years ago

applicationId和manefest包名不一致的问题已经修复,windows分隔符也修复了,详见最新版本v1.2.1