盒子
盒子

Android问题集锦

  • Unknown attribute android:layout_width…
  • Gradle版本问题

    ->Sync project with gradle file

  • …up-to-date check…
  • 可能时继承了某个接口,但又没有重写里面的所有方法

    重写继承了的接口的所有方法即可

  • 查看源码时显示Sources for ‘android api … platform’ not found
  • 按照提示后下载完成仍然无法看源码

    未配置源码路径

    修改.AndroidStudio3.1\config\options目录下的jdk.table.xml文件

    加上

    1
    <root url="file://F:/Soft/AndroidSDK/sources/android-28" type="simple" />

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ...
    <sourcePath>
    <root type="composite">
    <root url="file://F:/Soft/AndroidSDK/sources/android-28" type="simple" />
    </root>
    </sourcePath>
    </roots>
    <additional jdk="1.8" sdk="android-28" />
    ...

  • 在AsyncTask中的doInBackground除非执行完毕否则无法进入onPostExecute
  • Calling this method guarantees that onPostExecute(Object) is never invoked.

    调用此方法可确保永远不会调用onPostExecute

    不要调用 cancle(true) 方法

  • Error:(11) No resource identifier found for attribute ‘roundIcon’ in package
  • 删除AndroidManifest.xml里的 android:roundIcon=”@mipmap/ic_launcher_round”

  • OkHttp常见问题
  • .string不能用两次,否则报错,记得添加INTERNET权限

  • Installation failed with message Failed to finalize session
  • clean project 即可

  • java.lang.IllegalArgumentException: Service Intent must be explicit
  • 在android 5.0版本以后,service intent必须为显式指出

    1
    2
    3
    4
    Intent intent=new Intent("ADD");
    //if dismiss will error
    intent.setPackage("io.github.grooters.practicer.BindeRer");
    bindService(intent,serviceConnection,BIND_AUTO_CREATE);

  • android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class
  • 自定义控件需要重写以下构造方法:

    1
    2
    3
    public Viewer(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    }

  • org.gradle.api.resources.ResourceException: Could not get resource
  • Unfortunately you can’t have non-Gradle Java modules and Android-Gradle modules in one project.
  • Sync project with gradle file

  • 卸载后重新安装app提示签名不一致无法安装
  • 未完全卸载app,只需要在应用商店的应用管理中的安装管理中卸载掉app

  • Error:Execution failed for task ‘:app:lintVitalRelease’
  • 打包发布版apk时,你在错误或警告无法通过检测

    只需要在app中的build.gradle中添加:

    1
    2
    3
    4
    5
    6
    android{
    lintOptions {
    checkReleaseBuilds false
    abortOnError false
    }
    }

  • App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details. less… (Ctrl+F1)
    Adds URLs to get your app into the Google index, to get installs and traffic to your app from Google Search.
  • 在AndroidManefist.xml中添加

    1
    <action android:name="android.intent.action.VIEW"/>

    eg:

    1
    2
    3
    4
    5
    6
    7
    <activity android:name=".MainActivity" android:launchMode="standard">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

  • Could not find com.android.tools.build:aapt2:3.2.0-alpha14-4748712.
    Searched in the following locations:

    file:/D:/android_sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-alpha14-4748712/aapt2-3.2.0-alpha14-4748712.pom
  • 在project里的builde.gralde增加谷歌库

    1
    2
    3
    4
    5
    6
    allprojects {
    repositories {
    google()//新增的
    jcenter()
    }
    }
    支持一下
    扫一扫,支持Grooter
    • 微信扫一扫
    • 支付宝扫一扫