错误一
错误描述:android.view.InflateException: Binary XML file line #33: Error inflating class fragment
错误原因:类库不支持
解决方法:
- fragment导入android.support.v4.app.Fragment和android.support.v4.app.FragmentTransaction;
- activity继承FragmentActivity
错误二
错误描述:Error:Execution failed for task ‘:schoolpa:transformResourcesWithMergeJavaResForDebug’.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.belerweb/pinyin4j/pom.properties
错误原因:jar包重复
解决方法:
- 第一步:项目gradle-android节点下增加以下属性
packagingOptions {
exclude ‘META-INF/DEPENDENCIES’
exclude ‘META-INF/NOTICE’
exclude ‘META-INF/LICENSE’
exclude ‘META-INF/LICENSE.txt’
exclude ‘META-INF/NOTICE.txt’
exclude ‘META-INF/maven/com.belerweb/pinyin4j/pom.xml’
exclude ‘META-INF/maven/com.belerweb/pinyin4j/pom.properties’
}
dexOptions {
javaMaxHeapSize “4g” //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}第二步:同步项目,clean项目,rebuild项目,运行项目即可
错误三
错误描述:No tab content FrameLayout found for id xxx
错误原因:未知
解决方法:
- 删掉xml中的Tabwidget
错误四
错误描述:修改build.gradle文件导致卡死
错误原因:as会请求Google仓库,非代理情况下会不断重试
解决方法:
所以需要把相应的包给下了
错误五
错误描述:构建的时候某些库无法加载
错误原因:有些库使用的是远程仓库,所以加上远程仓库的地址就行,例如
repositories {
maven { url "https://jitpack.io" }
}