Tôi đang sử dụng cấu hình đơn giản sau trong một dự án ứng dụng Android.Cảnh báo Gradle: variant.getOutputFile() và variant.setOutputFile() không được chấp nhận
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0.0"
applicationVariants.all { variant ->
def file = variant.outputFile
def fileName = file.name.replace(".apk", "-" + versionName + ".apk")
variant.outputFile = new File(file.parent, fileName)
}
}
}
Bây giờ tôi đã cập nhật trình cắm Gradle thành v.0.13.0 và Gradle thành v.2.1. các cảnh báo sau đây xuất hiện:
WARNING [Project: :MyApp] variant.getOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.setOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.getOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.setOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
Tôi có thể viết lại kịch bản Groovy để loại bỏ cảnh báo không dùng nữa?
Bạn đã thực sự cố gắng chạy mã này chưa? Tôi nhận được 'Không thể tìm thấy tập tin thuộc tính 'trên com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated @ 4b50996.' Plugin android gradle này là tàn bạo. – Merk
@Merk Trên thực tế, có, tôi đến đây tìm kiếm một câu trả lời cho cùng một câu hỏi, và cuối cùng quản lý để làm cho nó làm việc với đoạn mã trên (mặc dù tôi đã có một số mã hơi khác nhau bên trong nếu). Có vẻ như bạn đã viết sai điều gì đó nếu bạn không thể tìm thấy 'tệp' thuộc tính, vì không có thuộc tính nào được sử dụng trong đoạn mã của tôi :) – Thorbear
Khó hiểu vì đây là dòng vi phạm: 'output.outputFile = new File (file.parent , "AppName_playstorebuild.apk") '. BTW Tôi đang sử dụng 'classpath' com.android.tools.build: gradle: 0.13.0'' – Merk