Android 常见bug及解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/c_he_n/article/details/87875401
  • 报错信息: error running default activity not found
    解决方法:只需要在manifest中activity中添加下面代码即可。
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

若是开发一个没有桌面图标的app,可以把action 中那么自定义下,通过startactivity来启动应用。

<intent-filter>
    <action android:name="custom name" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
  • 报错信息: No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    解决方法:下载老版本NDK(单击跳转),覆盖在安装在sdk目录下…\ndk-bundle\toolchains即可。

  • 报错信息:.\build\intermediates\res\merged\debug\values-v26\values-v26.xml
    Error:(5, 21) No resource found that matches the given name: attr ‘android:keyboardNavigationCluster’.
    Error:(5, 21) No resource found that matches the given name: attr ‘android:keyboardNavigationCluster’.
    一般对于报错信息比较少的,我们可以通过命令来构建,这样可以打印出很多信息,供我们排查问题。通过下面的命名来进行构建:

    • gradlew clean
    • gradlew build --stacktrace --info
      针对打印出来的信息进行排查和解决。
      出现这种问题因为Android Support Library version 26 兼容性问题,build.gradle 中做如下设置。

compileSdkVersion 26
buildToolsVersion “26.0.1”

compile ‘com.android.support:appcompat-v7:26.0.1’
compile ‘com.android.support:design:26.0.1’
compile ‘com.android.support:recyclerview-v7:26.0.1’
compile ‘com.android.support:cardview-v7:26.0.1’

猜你喜欢

转载自blog.csdn.net/c_he_n/article/details/87875401