Android开发下遇到的一些奇葩问题处理

2023-11-08

环境  :     MAC+ Android Studio ;


Q1 : Gradle Home not found 。  

        网上查到的解决方案比较少一些,如 gradle-wrapper.properties  配置错误等等。

Solution :  我的解决是。。。无意中点了Run Build.Gradle。造成点击运行按钮是运行工程里的Build,而不是APP。  切回来即可。
 

Q2 :  一个比较简单的layout里放了一个RecyclerView。RecyclerView代码如下:

    
<pre name="code" class="java"><android.support.v7.widget.RecyclerView
    android:id="@+id/rv_homerecycler"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:paddingBottom="@dimen/rv_margin"
    android:paddingLeft="@dimen/rv_margin"
    android:paddingRight="@dimen/rv_margin"
    android:paddingTop="@dimen/rv_margin"
    android:scrollbars="none"/>



 

编译通过。运行会报错如下:

Unable to start activity ComponentInfo(XXX) Error inflating class android.support.v7.widget.RecyclerView。

这个网上说法也不多。 无非是说Lib错了之类的。但是我的依赖库是 v7,21+的 还单独引用了 RecyclerView。 

S   :   用排除法 问题出在了

@dimen/rv_margin。

然而我在dimen中配置的很正确。值是8dp。 并不知道原因。改成8dp就解决了。

Q3:   正常引用ToolBar ,报错  :

org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
下文有一句 “not found abc_ic_ab_back_material"

有的人通过:

Use this code in your build.gradle file

    //for Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

If you are using Gradle 1.5 you’ll instead use 

defaultConfig {
        generatedDensities = []
    }

    // This is handled for you by the 2.0+ Gradle Plugin
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }

I think may be they are using vector draw-able compact underneath in other lib.found here

然而我这里并没有解决。

A: 在 Gradle中 加入 

	compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
    }
	上面方法没有解决问题的同学不妨用这个方法试试。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android开发下遇到的一些奇葩问题处理 的相关文章

  • 如何调试R程序(转载)

    R语言的调试重要性不言而喻 这段时间准备改进一个R的包 但由于接触R时间不长 中间的很多东西不懂 需要重新打包调试 以对里面的很多程序有深入了解 下面从几个方面分享一下我的收获 1 准备工作 a R软件的下载http cran r proj

随机推荐