Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library module中存在的assets文件,在增量编译后会无法找到 #26

Closed
pcyan opened this issue Aug 26, 2016 · 13 comments
Closed
Assignees
Labels

Comments

@pcyan
Copy link

pcyan commented Aug 26, 2016

在库项目中修改java文件,运行 'python freeline.py' 会编译不通过
修改资源文件,运行 'python freeline.py' 编译能够通过,但是运行会因为找不到某些资源而崩溃

@lomanyong
Copy link
Member

@pcyan 有具体日志吗?库项目都是支持的...

@pcyan
Copy link
Author

pcyan commented Aug 26, 2016

@lomanyong 修改java文件的话,报错是这样的

[ERROR] --------------------------------------------------------
[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------

警告: [options] 未与 -source 1.7 一起设置引导类路径                                                                                                                                   
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:10: 错误: 程序包io.pcyan.testapplication.R不存在                          
        public static class anim extends io.pcyan.testapplication.R.anim {
                                                                   ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:45: 错误: 程序包io.pcyan.testapplication.R不存在                          
        public static class array extends io.pcyan.testapplication.R.array {
                                                                    ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:49: 错误: 程序包io.pcyan.testapplication.R不存在                          
        public static class attr extends io.pcyan.testapplication.R.attr {
                                                                   ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:478: 错误: 程序包io.pcyan.testapplication.R不存在                         
        public static class bool extends io.pcyan.testapplication.R.bool {
                                                                   ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:488: 错误: 程序包io.pcyan.testapplication.R不存在                         
        public static class color extends io.pcyan.testapplication.R.color {
                                                                    ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:659: 错误: 程序包io.pcyan.testapplication.R不存在                         
        public static class dimen extends io.pcyan.testapplication.R.dimen {
                                                                    ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:962: 错误: 程序包io.pcyan.testapplication.R不存在                         
        public static class drawable extends io.pcyan.testapplication.R.drawable {
                                                                       ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:1355: 错误: 程序包io.pcyan.testapplication.R不存在                        
        public static class id extends io.pcyan.testapplication.R.id {
                                                                 ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:1759: 错误: 程序包io.pcyan.testapplication.R不存在                        
        public static class integer extends io.pcyan.testapplication.R.integer {
                                                                      ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:1784: 错误: 程序包io.pcyan.testapplication.R不存在                        
        public static class layout extends io.pcyan.testapplication.R.layout {
                                                                     ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:1902: 错误: 程序包io.pcyan.testapplication.R不存在                                
        public static class string extends io.pcyan.testapplication.R.string {
                                                                     ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:2514: 错误: 程序包io.pcyan.testapplication.R不存在                        
        public static class style extends io.pcyan.testapplication.R.style {
                                                                    ^
D:\workspace\TestLibrary_open\testapplication\build\freeline\freeline-backup-r\com\qiaoyun\qylibrary\R.java:2940: 错误: 程序包io.pcyan.testapplication.R不存在                        
        public static class styleable extends io.pcyan.testapplication.R.styleable {
                                                                        ^
D:\workspace\TestLibrary_open\qylibrary\src\main\java\com\qiaoyun\cguoguo\ui\activity\livepush\VideoLivePushUserActivity.java:68: 错误: 找不到符号                                    
        livePush_viewer_plv = (PLVideoView) viewStub.findViewById(R.id.livePush_viewer_plv);
                                                                      ^
  符号:   变量 livePush_viewer_plv                                                                                                                                                    
  位置: 类 id                                                                                                                                                                         
14 个错误                                                                                                                                                                             
1 个警告                                                                                                                                                                                 


修改资源文件增量编译可以通过,所以没有错误日志

@lomanyong
Copy link
Member

@pcyan 可以删除掉freelinefreeline_core文件夹,然后重新执行一下gradlew.bat initFreeline,再来看下这个问题是否还会复现。

还有后续的问题可以加入我们的微信群一起来讨论哈:

@pcyan
Copy link
Author

pcyan commented Aug 26, 2016

@lomanyong 删除掉 freelinefreeline_core文件夹后问题复现
但是删除掉所有 freeline 的文件,包括 .zip.py文件后,重新gradlew.bat initFreeline
修改库中的java文件可以增量编译
。。。
资源文件还是老样子,可以通过增量编译,但是还是崩溃
我们是会在库中打开 asset 中的一个字体,增量编译后提示找不到字体然后就崩溃了
打开字体走的是 android.graphics.Typeface

    /**
     * Create a new typeface from the specified font data.
     * @param mgr The application's asset manager
     * @param path  The file name of the font data in the assets directory
     * @return The new typeface.
     */
    public static Typeface createFromAsset(AssetManager mgr, String path) {
        if (sFallbackFonts != null) {
            FontFamily fontFamily = new FontFamily();
            if (fontFamily.addFontFromAsset(mgr, path)) {
                FontFamily[] families = { fontFamily };
                return createFromFamiliesWithDefault(families);
            }
        }
        throw new RuntimeException("Font asset not found " + path);
    }

就是在这里抛出了异常
sFallbackFonts 是在init()方法中初始化的
Typefaceinit()方法只会走一遍
所以我怀疑是增量编译后,内存被回收了,没有重新初始化Typeface导致抛出异常

@lomanyong
Copy link
Member

@pcyan windows下的initFreeline更新看来还存在问题,这块我会继续优化一下w

增量编译资源的问题,可以解压缩一下${main_module}/build/freeline/base-res.so这个文件,看下里面的assets文件夹里是否有你们的字体文件

@pcyan
Copy link
Author

pcyan commented Aug 26, 2016

@lomanyong ${main_module}/build/freeline/base-res.so 这个文件解压后assets只有apktime,并没有字体

@lomanyong
Copy link
Member

@pcyan 你们的字体文件是否是放在library module的assets文件夹中呢?

@pcyan
Copy link
Author

pcyan commented Aug 26, 2016

@lomanyong 是的
路径为 {library_module}/src/main/assets/font.ttf

@lomanyong
Copy link
Member

@pcyan 恩,这个地方是个bug,这个问题我今天跟进修复

@lomanyong lomanyong changed the title 不支持库项目修改的增量编译 library module中存在的assets文件,在增量编译后会无法找到 Aug 26, 2016
@lomanyong lomanyong added the bug label Aug 26, 2016
@lomanyong lomanyong self-assigned this Aug 26, 2016
@lomanyong
Copy link
Member

@pcyan 这个问题升级0.5.4版本后也可以解决了,可以升级试试看

@charvenhe
Copy link
Member

@pcyan 升级0.5.4 然后重新initFreeline试试吧

@pcyan
Copy link
Author

pcyan commented Aug 29, 2016

@lomanyong @charvenhe 更新到 0.5.4 后增量编译能够定位到 asset
非常感谢

@pcyan pcyan closed this as completed Aug 29, 2016
@smoothdvd
Copy link

用compile 'com.joanzapata.iconify:android-iconify-ionicons:2.2.2'的话,修改res后无法增量编译,会报java.lang.RuntimeException: Font asset not found iconify/android-iconify-ionicons.ttf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants