android开发过程中遇到错误的笔记

错误1:

03-01 04:32:12.351 31387-31387/com.example.administrator.g_international E/AsyncHttpRH: User-space exception detected!                                                             android.content.res.Resources$NotFoundException: String resource ID #0x0

解决问题:资源Id所需要填充是字符串而不是其他类型,根据错误代码提示找到对应位子,检查方法中参数是否按照所需要的类型来填充的。

错误2:

Execution failed for task ':compileDebugAidl'.  Java.lang.IllegalStateException: aidl is missing

解决问题:统一所有的module的build tools版本与compile sdk版本

错误3:

使用ScrollView时请注意:

ScrollView作为根视图时,它只能只有一个孩子

错误4:

ScrollView嵌套ViewPager时:ViewPager的内容会显示不全

解决办法是:ScrollView 中添加

android:fillViewport="true"

1.设置ViewPager固定的高度

2.如何让ViewPager的高度根据内容至适应了。

/**
 * 自动适应高度的ViewPager
 * @author 
 *
 */
public class CustomViewPager extends ViewPager {
 
    public CustomViewPager(Context context) {
        super(context);
    }
 
    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
 
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
 
        int height = 0;
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            int h = child.getMeasuredHeight();
            if (h > height)
                height = h;
        }
 
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
 
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

3.ScrollView嵌套ListView,Viewpager, GridView时活动冲突。

代码的连接:http://blog.csdn.net/lovexieyuan520/article/details/45173313

错误5:

Error:Conflict with dependency 'com.google.code.findbugs:jsr305'

解决方案:https://stackoverflow.com/questions/37347326/errorconflict-with-dependency-com-google-code-findbugsjsr305

 

4.在打包的过程中出现了:

"app_name" is not translated in "af" (Afrikaans), "am" (Amharic), "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "en-rGB" (English: United Kingdom), "en-rIN" (English: India), "es" (Spanish), "es-rUS" (Spanish: United States), "et-rEE" (Estonian: Estonia), "fa" (Persian), "fi" (Finnish), "fr" (French), "fr-rCA" (French: Canada), "hi" (Hindi), "hr" (Croatian), "hu" (Hungarian), "hy-rAM" (Armenian: Armenia), "in" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ka-rGE" (Georgian: Georgia), "km-rKH" (Khmer: Cambodia), "ko" (Korean), "lo-rLA" (Lao: Lao People's Democratic Republic), "lt" (Lithuanian), "lv" (Latvian), "mn-rMN" (Mongolian: Mongolia), "ms-rMY" (Malay: Malaysia), "nb" (Norwegian Bokmål), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "pt-rPT" (Portuguese: Portugal), "ro" (Romanian), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sr" (Serbian), "sv" (Swedish), "sw" (Swahili), "th" (Thai), "tl" (Tagalog), "tr" (Turkish), "uk" (Ukrainian), "vi" (Vietnamese), "zh-rCN" (Chinese: China), "zh-rHK" (Chinese: Hong Kong), "zh-rTW" (Chinese: Taiwan, Province of China), "zu" (Zulu)

 

是什么原因呢?原因如下:

在Android SDK Tool r19之后, Export的时候遇到xxx is not translated in yyy, zzz的问题。

例如说"auto_name" is not translated in zh, zh_CN.

这是因为Android SDK Tool 將 ANDROID_LINT_COMPLETE_REGIONS 改为了需要检查。

解决办法:

根据错误提示的log,自己尝试 :

(1)忽略:tools:ignore="MissingTranslation" 和(2)指定文件的语言:tools:locale="zh-rCN"

结果:设置res/value/string.xml文件的 tools:ignore="MissingTranslation" 属性,可以忽略导出apk时产生的错误。

<resources   
    xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools"  
    tools:ignore="MissingTranslation"  
    >     
    <string name="app_name">XXXX</string>  
</resources>  

 

转载于:https://my.oschina.net/quguangle/blog/848556

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值