Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Android annotation Encoding Problem #1746

Description

@CrazyClownSola

in case of Android annotation 3.2

if I write like this

MyActivity.class


/**
 * 获取布局
 */
@Extra("menu")
int menu_id;

then in MyActivity_.class


public MyActivity_.IntentBuilder_ menu_id(int menu_id) {
       return super.extra(MENU_ID_EXTRA, menu_id);
}

But in Android annotation 4.0

the same code

but in MyActivity_.class

  /**
         * 
         * ���ݴ�����
         * @param menu_id
         *     the value for this extra
         * @return
         *     the IntentBuilder to chain calls
         */
        public DetailListActivity_.IntentBuilder_ menu_id(int menu_id) {
            return super.extra(MENU_ID_EXTRA, menu_id);
        }

and this cause some error in Android Studio
like this

Error:(188, 12) 错误: 编码UTF-8的不可映射字符
Error:(188, 13) 错误: 编码UTF-8的不可映射字符
Error:(188, 14) 错误: 编码UTF-8的不可映射字符
Error:(188, 16) 错误: 编码UTF-8的不可映射字符
Error:(188, 17) 错误: 编码UTF-8的不可映射字符
Error:(188, 18) 错误: 编码UTF-8的不可映射字符
Error:(188, 19) 错误: 编码UTF-8的不可映射字符
Error:(188, 20) 错误: 编码UTF-8的不可映射字符
8 个错误
:main:compileRetrolambdaDebug
Error:Execution failed for task ':main:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Could I do something to deal with this problem?
Thanks

Activity

  1. dodgex commented on Apr 11, 2016

    @dodgex
    Member

    looks like Android Annotations does not generate UTF-8 files or has some other problems with your UTF-8 comments.

    as a workarounnd it should be able to fix the issue when you change your comment to

    /*
     * 获取布局
     */
    @Extra("menu")
    int menu_id;
    

    note that there is only one star in the first line of the comment. so it is just a multiline comment and no javadoc comment and AA should not try to copy the value to the generated class.

    @WonderCsabo any idea how we could fix that?

  2. WonderCsabo commented on Apr 11, 2016

    @WonderCsabo
    Member

    First, @CrazyClownSola you should try the following:

    android {
        ...
        compileOptions {
            encoding "UTF-8"
            ...
        }
    }
  3. CrazyClownSola commented on Apr 12, 2016

    @CrazyClownSola
    Author

    @WonderCsabo

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
            encoding "UTF-8"
        }
    }
    

    I do like this
    But it still cause some error in Android Studio

    Error:(154, 12) 错误: 编码UTF-8的不可映射字符
    Error:(154, 13) 错误: 编码UTF-8的不可映射字符
    Error:(154, 14) 错误: 编码UTF-8的不可映射字符
    Error:(154, 15) 错误: 编码UTF-8的不可映射字符
    
    
  4. WonderCsabo commented on Apr 12, 2016

    @WonderCsabo
    Member

    @dodgex i recall there was a similar issue to this, but i cannot find it. I think there i suggested to add a new processing flag, which modifies the encoding of the generated source files. Currently we use the platform default encoding, but that can be problematic, like in this case.

  5. dodgex commented on Apr 12, 2016

    @dodgex
    Member

    i can't remember of such an issue. but maybe use UTF-8 instead of the default? i think UTF-8 should be used for source files.

  6. WonderCsabo commented on Apr 12, 2016

    @WonderCsabo
    Member

    @dodgex i totally agree, but if somebody uses encoding "something", then the generated UTF-8 files will not be properly recognised by the compiler.
    Maybe we should set the default to UTF-8, and add the option to change it.

  7. dodgex commented on Apr 12, 2016

    @dodgex
    Member

    that sounds like a good solution

  8. self-assigned this
    on Apr 12, 2016
  9. WonderCsabo commented on Apr 12, 2016

    @WonderCsabo
    Member

    @CrazyClownSola as a workaround, you can try to change your platform default encoding to UTF-8. Not sure if it is possible in your case.

  10. WonderCsabo commented on Apr 13, 2016

    @WonderCsabo
    Member

    Implemented. @CrazyClownSola you can try the snapshot build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions