本文主要是介绍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项目出错及解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!