Android Studio 1.2 编译出来在手机上运行时显示乱码

91program
博客专家认证
2015-08-28 10:15:08
Android Studio 1.2 将 Eclipse 的程序导入后,参照网上的进行了一些修改,编译出来在手机上运行时显示乱码。
这是什么原因啊?
需要怎么修改可以让程序 在手机上运行时汉字显示不是乱码?以前使用 Eclipse 是正常的,没有乱码。
...全文
1125 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
acMiner 2017-06-12
  • 打赏
  • 举报
回复
为什么我按照5楼写的gradle文件之后,程序都跑不起来了,说是找不到Manifest文件
qq_37427724 2017-02-25
  • 打赏
  • 举报
回复
lz知道为什么编辑器里中文注释是乱码,而且改编码也没用么
Star-Counter 2016-12-12
  • 打赏
  • 举报
回复
可以可以,最后在这里解决了问题
renjianbuchai_233 2016-10-02
  • 打赏
  • 举报
回复
五楼的东西怎么用啊
yyyu_ 2016-01-05
  • 打赏
  • 举报
回复
5楼的是对的,,非常感谢
橙子哦哦 2015-10-28
  • 打赏
  • 举报
回复
感谢楼主,我碰到这个问题查了半天 最后在你这里解决了!
91program 2015-08-30
  • 打赏
  • 举报
回复
看来是高手不想回答这个简单的问题,还是自己在网上查出来了。

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':appcompat_v7')
}

android {
    compileSdkVersion 10
    buildToolsVersion "20.0.0"
    android {compileOptions.encoding = "GBK"}               /////////增加的内容,可以解决部署到设备上汉字显示乱码的问题

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}
sagittarius1988 2015-08-28
  • 打赏
  • 举报
回复
引用 2 楼 91program 的回复:
[quote=引用 1 楼 sagittarius1988 的回复:] 菜单File--Setting--Editor--File Encodings 设置下你的编码就行了
请看清楚,不是 Android Studio 中显示乱码哦 所以,和设置 Editor 的编码方式没有关系。[/quote] 你换种编码方式看看,可能是手机上的编码方式跟电脑上的不一样啊。就好像你pc上中文名文件正常显示,烤到手机上就乱码了一个道理啊
91program 2015-08-28
  • 打赏
  • 举报
回复
引用 1 楼 sagittarius1988 的回复:
菜单File--Setting--Editor--File Encodings 设置下你的编码就行了
请看清楚,不是 Android Studio 中显示乱码哦 所以,和设置 Editor 的编码方式没有关系。
sagittarius1988 2015-08-28
  • 打赏
  • 举报
回复
菜单File--Setting--Editor--File Encodings 设置下你的编码就行了
91program 2015-08-28
  • 打赏
  • 举报
回复
顶起,应该有人遇到过此现象啊!

80,363

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧