• Android开发遇到的问题


    1、导入某个现有project目录后。出现R资源不能resolve的错误,导致程序无法编译执行,此时右键->properties->android。看最上面的taget又没有选择对,勾选当前可选的最高那个版本号(即你本机已经安装的最高版本号的SDK),点击apply。错误解决。


    2、style.xml里出现样式无法识别:

    error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.

    也包含其它样式的此类错误,是由于:



    8down voteaccepted

    AppCompat is a library project. You need to reference the library project in your android project.

    https://developer.android.com/tools/support-library/setup.html

    Check the topic Adding libraries with resources.

    去这个地址看解决方法吧。


    參考我的还有一篇博文:

    点击打开链接


    3、Activity中使用addContentView(layoutPlatform, lpLl);方法动态加入了一个子view,layoutPlatform是LinearLayout类型的,作为view,我想在layoutPlatform这个子view里与Activity通信,即在子view里点击某个button之后。让Activity更新界面内容。这个实现方法是,在Activity中实现CallBack借口,重写它的handleMessage方法,然后在子view的button点击处理函数里给Activity发送message就可以。

    发送消息的方式是 handler.sendMessage();


    4、context转化为Activity,转化方法是:

    if (context instanceof Activity)
    {
    activity = (Activity)context;
    }

    5、addContentView 动态加入的view怎样移除呢?

    ViewGroup vg = (ViewGroup)layoutPlatform.getParent();
    vg.removeView(layoutPlatform);
    

    须要强转成为ViewGroup,然后remove就可以。


    6、导入其它项目进来时,它使用了使用android.support.v7库。所以导入之后报错,解决的方法是,在Android studio的程序目录里有sdk目录,里面存放着下载好的这个库的project。将它导入到eclipse里,然后再引用它就可以了。详细步骤:

        (1)import -> Existing Android Code Into Workspace 
        (2) 选择目录: 在sdk下的extrasandroidsupportv7appcompat目录中

        (3)勾选"Copy projects into workspace"

        (4)如出现 Unable to resolve target 'android-16' 错误,是build target版本号号问题,右键->properties->Android->build target。选择一个本机已经安装好的sdk版本号。
        (5)在你新project中右键->properties->Android->Library中add上面的库project就可以。

    參考:http://blog.csdn.net/xcl168/article/details/13613265

    7、The library 'wikitudesdk.jar' contains native libraries that will not run on the device。

    解决方法:window-》preference-》Android-》build-》“Force error when external jars contain native libraries”.选项关闭就可以。


    8、再引入第三方lib或者jar包时,编译通过,可是执行不了,报错例如以下:

    java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat

    我使用的是Android support V4那个jar包。解决的方法是在libs/xxx,jar文件上右键->Use as source folder 就可以。


    9、project上有红色叹号或者编译不了,右键->properties,查看Android选项,是否引用了本地的libproject,然后查看Java Build Path选项卡。Order and Export中假设有missing的project。说明它引用了其它project,可是那些project在本地不存在,到Porjets 选项中删除这些missing的project;


    10、执行project时出现:

    1
    2
    Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

    右键-》property-》java build path-》Order and Export-》把带勾的项所有取消勾选 就可以;


    待续。。

  • 相关阅读:
    robotframework学习笔记七:robotframework的数据驱动模式
    robotframework学习笔记六:Set Variable If 关键字的使用
    robotframework学习笔记五:robotframework控制流if和for
    C# BS方向 该如何规划学习?【学习路线指南】
    毕业四年,我当初是如何走上编程这条路的!
    设计模式之备忘录
    设计模式之中介者
    设计模式之迭代器
    设计模式之命令模式
    nginx 499 错误解决
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10949030.html
Copyright © 2020-2023  润新知