Coder Social home page Coder Social logo

编译成功运行失败。。 about tucao HOT 10 CLOSED

quert999 avatar quert999 commented on July 1, 2024 1
编译成功运行失败。。

from tucao.

Comments (10)

quert999 avatar quert999 commented on July 1, 2024 1

懂了,谢谢dalao

from tucao.

quert999 avatar quert999 commented on July 1, 2024

翻了一下gradle console,找到以下报错:

Note: there were 11 duplicate class definitions.

e: 错误: Exception while handling step android.databinding.annotationprocessor.ProcessExpressions@2515ecd5 javax.xml.bind.UnmarshalException
e:

e: - with linked exception:
e: [com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 3 无效。]

from tucao.

blackbbc avatar blackbbc commented on July 1, 2024

#4

from tucao.

quert999 avatar quert999 commented on July 1, 2024

我在每个build.gradle文件都添加了task,依然报这个错。。

from tucao.

quert999 avatar quert999 commented on July 1, 2024

给dalao递茶,求dalao指导= =。

from tucao.

blackbbc avatar blackbbc commented on July 1, 2024

那篇博客给出的task方法我没有试过
但是根本解决方法是将所有含有中文的地方都用@string代替

例如

<TextView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text='@{"共:" + viewModel.totalCount + "个相关结果"}'
    android:textColor="@color/secondary_text"
    android:textSize="12sp"
    android:visibility="@{viewModel.totalCountVisibility}"
    tools:text="共:274个相关结果" />

在values/strings.xml里加入如下字符串

<string name="gong">共</string>
<string name="jieguo">个相关结果</string>

然后上面的android:text替换成

android:text='@{@string/gone + viewModel.totalCount + @string/jieguo}'

我不这么做的原因有以下几个:

  1. 工作量太大了,所有有中文的地方都要替换
  2. 我主要针对国内用户,不用做多语言支持
  3. 不优雅,破坏了Databinding直观的体验
  4. 我是Linux用户

from tucao.

quert999 avatar quert999 commented on July 1, 2024

我去试试, 拜谢dalao

from tucao.

guuguo avatar guuguo commented on July 1, 2024

@blackbbc 我试了下 不需要修改全部中文,databinding表达式中的中文改成@string就行了,
也不会太影响效果。项目就四五处需要修改。
例如:
android:text='@{"播放:"+viewModel.result.play}' 改成
android:text='@{@string/play+viewModel.result.play}'

from tucao.

WinDerek avatar WinDerek commented on July 1, 2024

Windows下添加一个环境变量JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8即可
@quert999

from tucao.

quert999 avatar quert999 commented on July 1, 2024

@DerekDick dalao给力

from tucao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.