1.uses-sdk:minSdkVersion 1 cannot be smaller than version 4 declared in library [com.android.support:sup
根據報錯提示:最低兼容版本api 1低於v7兼容類庫的api 7,找到app的gradle發現設置了最低兼容9,並不是1啊.
android { ... defaultConfig { minSdkVersion 10 targetSdkVersion 19 } ... }
完美搞定 perfect
2.Failed to execute aapt
這個在網上也收到過一些
1.apt-get install lib32stdc++6
2.在SDK Tool中添加需要的tools
3,我是把項目冊了重新添加完成的,本質就是R文件找不到了
3. Error: java.lang.RuntimeException: Crunching Cruncher ic_launcher.png failed, see logs
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
4.Error:Application and test application id cannot be the same: both are 'com.itheima.im3' for debugAndroidTest
把這個刪除就Ok了 很簡單的
/*testApplicationId "com.itheima.im3"
testInstrumentationRunner "android.test.InstrumentationTestRunner"*/
5.java: 類重復: com.xx.R解決方法
藍色部分表示打包時包含在Source內, 下面是遇到的兩個問題
1. src目錄未選成Sources導致所有類文件未被編譯到生成的包內。
2. 錯誤的把整個工程選中Sources,導致 R文件及gen下的其他文件出現類重復。
3.把代&的類刪除,
6.Installation failed with message INSTALL_CANCELED_BY_USER.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present,
and then re-installing.
1. 確保手機處於開發者模式。
2. 在手機上,勾選 系統設置->安全->未知來源 ,然后重試。
3. 安裝的時候手機是否處於鎖屏狀態,若是的話,取消鎖屏。
4. 有的手機需要手動安裝。如小米3 小米手機還要在開發模式中開啟install via USB
4. 其他的就是手機內存空間之類的啦。
7. Error: A library uses the same package as this project: com.minisea.example
You can add enforceUniquePackageName=false in the app modules build.gradle file under android:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
enforceUniquePackageName = false ... }
8. Multiple dex files define Lcom/minisea/example/BuildConfig;
在Build
android中加入
enforceUniquePackageName = false
9.
<span style="font-family: Arial, Helvetica, sans-serif; ">一</span>
今天打開AndroidStudio, 莫名其妙的全部工程都報錯了,丟了個這樣的錯誤:
Gradle sync failed: Could not run build action using Gradle installation 'D:\Android-studio-2.0-pre4
解決方法:File -> Settings -> 搜索Gradle 配置下Gradle的路徑,並且把離線編譯選項給勾上。
10.新建項目出現沒找到資源的錯誤!找不到com.android.support/appcompat-v7/23.0.1/res/values-v23/values-v23.xml
No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
這是API 23(Android 6.0)中的資源文件,而查看build.gradle,編譯的SDK只是為21,我們可以嘗試將compileSdkVersion設為23
如果不想下載API 23怎么解決呢?降低appcompat的版本:將build.gradle里面的dependencies對應的appcompat版本降低:
在dependencies中將compile 'com.android.support:appcompat-v7:23.0.1'的版本改為:'com.android.support:appcompat-v7:22.2.1'
11.
Error:Error converting bytecode to dex:
- Cause: java.lang.RuntimeException: Translation has been interrupted
compileSdkVersion 25
buildToolsVersion "25.0.0"
//添加如下代碼即可解決
dexOptions {
javaMaxHeapSize "4g"
}
}
13. Theme.AppCompat.Light無法找到問題
使用adt開發新建一個Android app,選擇支持的SDK版本如果小於11(Android3.0)就會報如下錯誤。
No resource found that matches the given name 'Theme.AppCompat.Light'.
簡單來說就是新的eclipse默認模版主題UI需要使用比較高版本api,如果需要支持低版本,需要導入appCompact庫來支持,網上一般給出的解法:
File->Import (android-sdk\extras\android\support\v7). Choose "appcompat"
Project-> properties->Android. In the section library "Add" and choose "appCompat"
14.Parse Error
路徑或是包名大寫了
15.AS的代碼編輯窗口中和運行時,中文顯示亂碼
解決:AS的代碼編輯窗口中的亂碼,只需要把IDE右下角的UTF-8改為GBK;運行時顯示亂碼,1、在project->app->build.gradle中添加compileOptions.encoding = "GBK"。2、不能在布局文件中直接輸入中文,需要在R文件中注冊下,比如<activity android:label="中文" >改為<activity android:label="@string/chinese" >,在strings.xml中添加<string name="chinese">中文</string>。
16.app:transformNative_libsWithStripDebugSymbolForDebug
這一是個關於Android studio配置jni時候出現的錯誤
//ndk.dir=D\:\\Android_SDK\\ndk-bundle 把ndk去掉
17.Manifest merger failed with multiple errors, see ?
這個問題困擾了我半天,最后終於解決了
嘗試的方法有:
1.很大可能是SDK版本,建議給出log看一下
2.
> Manifest merger failed with multiple errors, see logs這句話的上面顯示的error日志,它說的很清楚,我也出現這個問題.原因是導入的庫在build.gradle中的minSdkVersion與你的應用的minSdkVersion不 匹配導致的(app要求應用最小系統版本和庫要求系統最小版本不一致),改成一樣的就行了
tools:replace="icon, label, theme,allowBackup"
方法1:在Manifest.xml的application標簽下添加tools:replace=”android:icon, android:theme”(多個屬性用,隔開,並且記住在manifest根標簽上加入 xmlns:tools=”http://schemas.android.com /tools”,否則會找不到namespace哦)
方法2:在build.gradle根標簽上加上useOldManifestMerger true (懶人方法)
- aaptOptions.cruncherEnabled = false
- aaptOptions.useNewCruncher = false

compile ('in.srain.cube:cube-sdk:1.0.42.1'){ exclude module: 'support-v4' }
去掉in.srain.cube:cube-sdk:1.0.42.1中的包不加載即可。
20.v4包中MergingForDebu的問題
Ctrl+N --> 在搜索框中輸入BackStackState --> 查找到所有引用該類的類,這些類即為引起沖突的類
21 .UnsupportedMethodException

22 .依賴包沖突解決辦法
項目中使用的library版本是23,但是項目引用的包引用的library版本是24,這樣就會出現沖突,報錯如下:
解決辦法,使用exclude,排除沖突的依賴包:
compile ('com.bat:apploginsdk:1.0.1') { // exclude module : 'okhttp' // exclude module : 'com.android.support' exclude group: 'com.android.support', module: 'recyclerview-v7' exclude group: 'com.android.support', module: 'support-v4' exclude group: 'com.android.support', module: 'design' exclude group: 'com.android.support', module: 'appcompat-v7' }
23.compileSdkVersion rootProject.ext.android["compileSdkVersion"]sdk版本問題?
defaultConfig {
applicationId "me.jessyan.mvparms.demo"
//...
jackOptions { //加上這句可以嘗試下
enabled true
}
}
24.Error retrieving parent for item: No resource found that matches
看看你的build.gradle文件里面的compileSdkVersion
和compile 'com.android.support:'版本是不是對應的
25.Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer
一般都是applay from 引起的
25.R文件找不到是經常遇到的問題
1.導包的正確
2.清理緩存
3.clear,reBuild,MakePorject,最后inValidate Cache
26.亂碼問題,GBK不能映射字符
allprojects {
tasks.withType(Javadoc) {
options{
encoding "UTF-8"
charSet 'UTF-8'
}
}
}
27.android.system.ErrnoException: open failed: EACCES (Permission denied)
這個是因數權限的問題,解決問題有:
1.可以在代碼中添加權限
2.targetSdkVersion 改為小於23的就行
28.昨天在寫相冊的時候,目錄怎么就提示有問題(No such file or directory)
是因為dir.mkdir()和dir.mkdirs()的不同,
29.The specified child already has a parent. You must call removeView() on the child's parent first //放到for下面就可以了
我是把自定義的view放在了for外面導致的
