任务 compilefreeDebugKotlin 的 Android Studio 执行失败
Posted
技术标签:
【中文标题】任务 compilefreeDebugKotlin 的 Android Studio 执行失败【英文标题】:Android Studio Execution failed for task compilefreeDebugKotlin 【发布时间】:2015-02-09 08:05:06 【问题描述】:Kotlin android Gradle
我无法编译我的 Kotlin Android 应用程序
我的 gradle 构建失败并出现错误:
Error:Execution failed for task ':app:compilefreeDebugKotlin'.
> com.android.build.gradle.api.BaseVariant.getProcessResources()Lcom/android/build/gradle/tasks/ProcessAndroidResources;
在我的项目中,我描述了一个简单的适配器
import android.widget.TextView
import android.content.Context
import java.util.ArrayList
import com.idunnololz.widgets.AnimatedExpandableListView
import android.view.View
import android.view.ViewGroup
import android.view.LayoutInflater
public class ExpListAdapter(vcontext: Context, vgroups: ArrayList<String>, vtitles: ArrayList<ArrayList<String>>) : AnimatedExpandableListView.AnimatedExpandableListAdapter()
var titles = vtitles
var context = vcontext
var groups = vgroups
override fun getGroupCount(): Int = titles.size()
override fun getGroup(groupPosition: Int): Any = titles.get(groupPosition)
override fun getChild(groupPosition: Int, childPosition: Int): Any = titles.get(groupPosition).get(childPosition)
override fun getGroupId(groupPosition: Int): Long = groupPosition.toLong()
override fun getChildId(groupPosition: Int, childPosition: Int): Long = childPosition.toLong()
override fun hasStableIds(): Boolean = true
override fun getGroupView(groupPosition: Int, isExpanded: Boolean, convertView: View?, parent: ViewGroup): View?
var convertView = convertView
if ( convertView == null)
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
convertView = inflater.inflate(R.layout.start_parent, parent, false)
val textGroup = convertView?.findViewById(R.id.tv_parent_size) as TextView
textGroup.setText(groups.get(groupPosition))
val textGroupnum = convertView?.findViewById(R.id.tv_parent_numbet) as TextView
textGroupnum.setText(java.lang.String.valueOf(groupPosition + 1))
return convertView as View
override fun getRealChildView(groupPosition: Int, childPosition: Int, isLastChild: Boolean, convertView: View?, parent: ViewGroup): View?
var convertView = convertView
if (convertView == null)
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
convertView = inflater.inflate(R.layout.start_childer, parent, false)
val textChild = convertView!!.findViewById(R.id.tv_children_name) as TextView
textChild.setText(titles.get(groupPosition).get(childPosition))
return convertView as View
override fun getRealChildrenCount(groupPosition: Int): Int = titles.get(groupPosition).size()
override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean = true
为了编译,我使用了默认的 gradle 构建脚本和 Android Studio 1.0.0
【问题讨论】:
【参考方案1】:尝试在build.gradle
文件中将kotlin-gradle-plugin
版本更新为0.9.976。
buildscript
repositories
mavenCentral()
dependencies
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.9.976'
【讨论】:
以上是关于任务 compilefreeDebugKotlin 的 Android Studio 执行失败的主要内容,如果未能解决你的问题,请参考以下文章