Android studio3.0.1导入GitHub项目出错及解决方法

2023-12-23 04:58

本文主要是介绍Android studio3.0.1导入GitHub项目出错及解决方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

准备:

1、project的build.gradle: classpath 要修改成自己Android studio支持的版本。

buildscript {repositories {jcenter()}dependencies {classpath 'com.android.tools.build:gradle:3.0.1'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}allprojects {repositories {jcenter()mavenCentral()}
}
task clean(type: Delete) {delete rootProject.buildDir
}

2、gradle-wrapper.properties : distributionUrl要修改成自己Android studio支持的版本

#Wed Sep 21 10:34:57 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

一、gradle打包,自定义apk名称代码报错:

Error:(34, 1) A problem occurred configuring project ':app'.
> Cannot set the value of read-only property 'outputFile' 
for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} 
of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

解决办法:
1、将variant.outputs.each 改为 variant.outputs.all
2、将output.outputFile 改为 outputFileName
示例如下:
修改前:

//apk命名
android.applicationVariants.all { variant ->variant.outputs.each { output ->def outputFile = output.outputFileif (outputFile != null && outputFile.name.endsWith('.apk')) {//这里修改apk文件名def fileName = "AndroidFire_${defaultConfig.versionCode}" +"_${defaultConfig.versionName}_${releaseTime()}.apk"output.outputFile = new File(outputFile.parent, fileName)}}
}

修改后:

//apk命名
android.applicationVariants.all { variant -> //variant.outputs.each { output ->                                    //3.0以下variant.outputs.all { output ->                                       //3.0以上def outputFile = output.outputFileif (outputFile != null && outputFile.name.endsWith('.apk')) {//这里修改apk文件名def fileName = "AndroidFire_${defaultConfig.versionCode}" +"_${defaultConfig.versionName}_${releaseTime()}.apk"//output.outputFile = new File(outputFile.parent, fileName)    //3.0以下     outputFileName = fileName                                      //3.0以上}}
}

参考:Android studio 3.0 引起的自定义打包文件名 outputFile sync failed

二、butterknife出错

Error:Execution failed for task ':library:common:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now.  
The following dependencies on the compile classpath are found to contain annotation processor.  
Please add them to the annotationProcessor configuration.- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

解决办法:

android{defaultConfig {applicationId "jaydenxiao.com.androidfire"minSdkVersion 15targetSdkVersion 24versionCode 4versionName "1.0.3"// 声明需要使用注解功能,所依赖的gradle都需要添加javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
}

会过时。

Android studio中 安装 ButterKnife Zelezny插件安装不了

到官网 https://github.com/avast/android-butterknife-zelezny 离线下载
然后 file–>settings–>Plugins–>Install plugin from disk–>
然后选择下载好的jar文件并Ok确认–>最后重启studio工具(一定要重启)

参考:
Android ButterKnife Zelezny插件的安装与使用

三、属性已弃用

Warning:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.  

解决办法:
将代码中去掉该incremental 的设置即可。

android{//设置虚拟机堆内存空间大小,避免在编译期间OOMdexOptions {incremental truejavaMaxHeapSize "4g"}
}	

四:style的@问题

Error:(35, 5) error: style attribute '@android:attr/windowEnterAnimation' not found.
Error:(35, 5) error: style attribute '@android:attr/windowExitAnimation' not found.
E:\GitHubGoods\AndroidFire\library\selectordialog\build\intermediates\bundles\debug\res\values\values.xml

解决办法一:

gradle.property中添加:

android.enableAapt2=false

解决方法二:
提示我们找不到@android:attr/windowEnterAnimation,
因为已经不支持@开头使用android自带的属性,我们只要把@符号删掉就可以了。
修改前:

<style name="ToastStyle" parent="android:Animation"><item name="@android:windowEnterAnimation">@anim/push_fade_in</item><item name="@android:windowExitAnimation">@anim/push_fade_out</item>
</style>

修改后:

<style name="ToastStyle" parent="android:Animation"><item name="android:windowEnterAnimation">@anim/push_fade_in</item><item name="android:windowExitAnimation">@anim/push_fade_out</item>
</style>

这篇关于Android studio3.0.1导入GitHub项目出错及解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/526781

相关文章

Android 12解决push framework.jar无法开机的方法小结

《Android12解决pushframework.jar无法开机的方法小结》:本文主要介绍在Android12中解决pushframework.jar无法开机的方法,包括编译指令、框架层和s... 目录1. android 编译指令1.1 framework层的编译指令1.2 替换framework.ja

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

Android实现定时任务的几种方式汇总(附源码)

《Android实现定时任务的几种方式汇总(附源码)》在Android应用中,定时任务(ScheduledTask)的需求几乎无处不在:从定时刷新数据、定时备份、定时推送通知,到夜间静默下载、循环执行... 目录一、项目介绍1. 背景与意义二、相关基础知识与系统约束三、方案一:Handler.postDel

在.NET平台使用C#为PDF添加各种类型的表单域的方法

《在.NET平台使用C#为PDF添加各种类型的表单域的方法》在日常办公系统开发中,涉及PDF处理相关的开发时,生成可填写的PDF表单是一种常见需求,与静态PDF不同,带有**表单域的文档支持用户直接在... 目录引言使用 PdfTextBoxField 添加文本输入域使用 PdfComboBoxField

SQLyog中DELIMITER执行存储过程时出现前置缩进问题的解决方法

《SQLyog中DELIMITER执行存储过程时出现前置缩进问题的解决方法》在SQLyog中执行存储过程时出现的前置缩进问题,实际上反映了SQLyog对SQL语句解析的一个特殊行为,本文给大家介绍了详... 目录问题根源正确写法示例永久解决方案为什么命令行不受影响?最佳实践建议问题根源SQLyog的语句分

Python开发文字版随机事件游戏的项目实例

《Python开发文字版随机事件游戏的项目实例》随机事件游戏是一种通过生成不可预测的事件来增强游戏体验的类型,在这篇博文中,我们将使用Python开发一款文字版随机事件游戏,通过这个项目,读者不仅能够... 目录项目概述2.1 游戏概念2.2 游戏特色2.3 目标玩家群体技术选择与环境准备3.1 开发环境3

Java NoClassDefFoundError运行时错误分析解决

《JavaNoClassDefFoundError运行时错误分析解决》在Java开发中,NoClassDefFoundError是一种常见的运行时错误,它通常表明Java虚拟机在尝试加载一个类时未能... 目录前言一、问题分析二、报错原因三、解决思路检查类路径配置检查依赖库检查类文件调试类加载器问题四、常见

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

Java 中的 @SneakyThrows 注解使用方法(简化异常处理的利与弊)

《Java中的@SneakyThrows注解使用方法(简化异常处理的利与弊)》为了简化异常处理,Lombok提供了一个强大的注解@SneakyThrows,本文将详细介绍@SneakyThro... 目录1. @SneakyThrows 简介 1.1 什么是 Lombok?2. @SneakyThrows

MyBatis模糊查询报错:ParserException: not supported.pos 问题解决

《MyBatis模糊查询报错:ParserException:notsupported.pos问题解决》本文主要介绍了MyBatis模糊查询报错:ParserException:notsuppo... 目录问题描述问题根源错误SQL解析逻辑深层原因分析三种解决方案方案一:使用CONCAT函数(推荐)方案二: