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 kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

Android ClassLoader加载机制详解

《AndroidClassLoader加载机制详解》Android的ClassLoader负责加载.dex文件,基于双亲委派模型,支持热修复和插件化,需注意类冲突、内存泄漏和兼容性问题,本文给大家介... 目录一、ClassLoader概述1.1 类加载的基本概念1.2 android与Java Class

Java 方法重载Overload常见误区及注意事项

《Java方法重载Overload常见误区及注意事项》Java方法重载允许同一类中同名方法通过参数类型、数量、顺序差异实现功能扩展,提升代码灵活性,核心条件为参数列表不同,不涉及返回类型、访问修饰符... 目录Java 方法重载(Overload)详解一、方法重载的核心条件二、构成方法重载的具体情况三、不构

SQL中如何添加数据(常见方法及示例)

《SQL中如何添加数据(常见方法及示例)》SQL全称为StructuredQueryLanguage,是一种用于管理关系数据库的标准编程语言,下面给大家介绍SQL中如何添加数据,感兴趣的朋友一起看看吧... 目录在mysql中,有多种方法可以添加数据。以下是一些常见的方法及其示例。1. 使用INSERT I

Python中反转字符串的常见方法小结

《Python中反转字符串的常见方法小结》在Python中,字符串对象没有内置的反转方法,然而,在实际开发中,我们经常会遇到需要反转字符串的场景,比如处理回文字符串、文本加密等,因此,掌握如何在Pyt... 目录python中反转字符串的方法技术背景实现步骤1. 使用切片2. 使用 reversed() 函

Python中将嵌套列表扁平化的多种实现方法

《Python中将嵌套列表扁平化的多种实现方法》在Python编程中,我们常常会遇到需要将嵌套列表(即列表中包含列表)转换为一个一维的扁平列表的需求,本文将给大家介绍了多种实现这一目标的方法,需要的朋... 目录python中将嵌套列表扁平化的方法技术背景实现步骤1. 使用嵌套列表推导式2. 使用itert

Python使用pip工具实现包自动更新的多种方法

《Python使用pip工具实现包自动更新的多种方法》本文深入探讨了使用Python的pip工具实现包自动更新的各种方法和技术,我们将从基础概念开始,逐步介绍手动更新方法、自动化脚本编写、结合CI/C... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

在Linux中改变echo输出颜色的实现方法

《在Linux中改变echo输出颜色的实现方法》在Linux系统的命令行环境下,为了使输出信息更加清晰、突出,便于用户快速识别和区分不同类型的信息,常常需要改变echo命令的输出颜色,所以本文给大家介... 目python录在linux中改变echo输出颜色的方法技术背景实现步骤使用ANSI转义码使用tpu

Conda与Python venv虚拟环境的区别与使用方法详解

《Conda与Pythonvenv虚拟环境的区别与使用方法详解》随着Python社区的成长,虚拟环境的概念和技术也在不断发展,:本文主要介绍Conda与Pythonvenv虚拟环境的区别与使用... 目录前言一、Conda 与 python venv 的核心区别1. Conda 的特点2. Python v

Spring Boot中WebSocket常用使用方法详解

《SpringBoot中WebSocket常用使用方法详解》本文从WebSocket的基础概念出发,详细介绍了SpringBoot集成WebSocket的步骤,并重点讲解了常用的使用方法,包括简单消... 目录一、WebSocket基础概念1.1 什么是WebSocket1.2 WebSocket与HTTP