CLL

Sunshine always comes after the rain

Welcome to my personal station!



正在加载今日诗词....

Android开发常见错误收集

目录

调试程序出现安装错误

AS发布项目到手机出现如下错误:

It is possible that issue is resolved by uninstalling an existing version of the apk if it is present,an then re-installing warning :uninstalling will remove the application data!

发布几次死活装不上去,clean project 也没有用,最后找到了问题解决方案,file-settings-搜索instant run,然后都取消,点击apply就可以正常发布到手机了。估计是android studio 的instant run 的bug,把instant run 选项去掉,编译安装就成功了。

Error: is not translated in “en” (English)

开发中出现以下错误的处理

Error:” “ is not translated in “en” (English) [MissingTranslation]”

最终在StackOverFlow上找到了解决方法,大概有这么几种方法,现整理如下:

  • 尝试添加translatable=”[true / false]”
 <string name="junkchen" translatable="false">Junk Chen!</string>  
  • 在resources中添加属性
   <resources 
        xmlns:tools="http://schemas.android.com/tools"
        tools:ignore="MissingTranslation" >
  • 指定语言
   <resources 
        xmlns:tools="http://schemas.android.com/tools"
        tools:locale="en" >
    </resources>
  • 使用Android studio可以在build.gradle中的android中添加lintOptions
 lintOptions {
        disable 'MissingTranslation'
    }

或者

  lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

android 高德地图系统签名后定位失败解析

  1. 首先,大家知道高德地图定位,服务端申请key,需要sha1值
  2. sha1值获取方式,不阐述了,百度一大堆。
  3. 在调试时候,使用的是androidstudio 的签名,sha1值ok
  4. 在使用系统签名文件,签名后,定位一直是0.
  5. 原来是sha1值改变,导致的失败。

    获取系统签名sha1值

  1. 系统签名apk文件,解压(重命名为rar文件)
  2. 取出META_INFO中CERT.RSA文件。
  3. cmd下执行keytool -printcert -file CERT.RSA路径。
  4. 将sha1值添加到高德key中,可以为发布sha1,讲studio的sha1更改为调试sha1.
    编译、签名、安装、定位,可以实现定位了。

2018-11-15 11:49:09 更新:

Warning:Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’.

在Android编译项目时,出现以下错误:

Warning:Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.0.0) and test app (25.4.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

build.gradle依赖部分如下:

compile fileTree(dir: ‘libs’, include: [‘*.jar’])
compile ‘com.android.support:appcompat-v7:26.0.0’
compile ‘com.android.support.constraint:constraint-layout:1.0.2’
testCompile ‘junit:junit:4.12’
androidTestCompile ‘com.android.support.test:runner:1.0.0’
androidTestCompile ‘com.android.support.test.espresso:espresso-core:2.2.2’

我们进入提示的网页 http://g.co/androidstudio/app-test-app-conflict :

Resolving conflicts between main and test APK
When instrumentation tests are run, both the main APK and test APK share the same classpath. Gradle build will fail if the main APK and the test APK use the same library (e.g. Guava) but in different versions. If gradle didn’t catch that, your app could behave differently during tests and during normal run (including crashing in one of the cases).
To make the build succeed, just make sure both APKs use the same version. If the error is about an indirect dependency (a library you didn’t mention in your build.gradle), just add a dependency for the newer version to the configuration (“compile” or “androidTestCompile”) that needs it. You can also use Gradle’s resolution strategy mechanism. You can inspect the dependency tree by running ./gradlew :app:dependencies and ./gradlew :app:androidDependencies.

看来问题找到了,runner:1.0.0 引用了25.4.0导致的。。。 按照上面英文说明修改如下:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])    
compile 'com.android.support:appcompat-v7:26.0.0'    
compile 'com.android.support.constraint:constraint-layout:1.0.2'   
testCompile 'junit:junit:4.12'   
androidTestCompile 'com.android.support.test:runner:1.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support:support-annotations:26.0.0'
}

只需要添加:

 androidTestCompile 'com.android.support:support-annotations:26.0.0'

就可以了.

Error:Could not find support-compat.jar (com.android.support:support-compat:27.1.1).

编译报错(或者类似错误):androidstudio2.3.3

Error:Could not find support-compat.jar (com.android.support:support-compat:27.1.1). Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-compat/27.1.1/support-compat-27.1.1.jar

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager

解决办法:

把Google库放在jcenter库前面

buildscript {
repositories {
    maven { url "https://maven.google.com" }
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    maven { url "https://maven.google.com" }
    jcenter()
    maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {    delete rootProject.buildDir
}

2019-2-20更新 升级Androidstudio3.3 编译出现

Android Cannot access ActivityCompatApi23 class 或者 无法访问:ActivityCompatApi23

解决办法: 改变compile ‘com.android.support:appcompat-v7:26.0.0-alpha1’至更高版本:

compile ‘com.android.support:appcompat-v7:26.+’

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝/微信扫一扫,即可进行扫码打赏哦