我正在使用此代码
applicationVariants.all { variant ->
variant.outputs.each { output ->
def SEP = "_"
def flavor = variant.productFlavors[0].name
def buildType =
variant.variantData.variantConfiguration.buildType.name
def version = variant.versionName
def date = new Date()
def formattedDate = date.format('ddMMyy_HHmm')
def newApkName = PROJECT_NAME + SEP + flavor + SEP + buildType + SEP + version + SEP + formattedDate + ".apk"
def file = new File(newApkName)
output.outputFile = file
}
}
Run Code Online (Sandbox Code Playgroud)
当我构建新的apk时更改apk文件的名称,但由于我使用Android Studio 3.0 Canary 2出现此错误:
无法设置只读属性'outputFile'的值....
我正在使用Android工作室,我想在我的项目中添加模块,如"action bar Sherlock"或jar文件,但是当我打开项目结构时,菜单中没有模块或库:\
在intelij它出现:
所以有什么问题?如何在Android studio中添加这些模块?
我有Interface
与Generic Type
public interface IWork<T>
{
void Work(MySession session, T json);
}
Run Code Online (Sandbox Code Playgroud)
尝试此代码时Classes
,我试图找到所有实现Interface
所有泛型类型的
var type = typeof(IWork<>);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
Run Code Online (Sandbox Code Playgroud)
它返回Interface
它自己。
我试图ArrayList<Integer>
从片段传递到另一个片段,这是我的代码:
科特林代码
companion object {
fun newInstance(categoryId: Int, brandsList: ArrayList<Int>): Fragment {
val fragment = CategoryAllAdsFragment()
fragment.arguments = Bundle()
fragment.arguments!!.putInt(Constant.CATEGORY_ID, categoryId)
fragment.arguments!!.putParcelableArrayList(Constant.BRANDS_LIST, brandsList)
return fragment
}
}
Run Code Online (Sandbox Code Playgroud)
但它说:
类型不匹配。
必需: java.util.ArrayList !
发现:kotlin.collections.ArrayList /* = java.util.ArrayList */
当我试图阅读它时,也是同样的事情。
科特林代码
try {
val brandsList = arguments!!.getParcelableArrayList<Int>(Constant.BRANDS_LIST)
} catch (ex: Exception) {
throw Exception("brand list cannot be null")
}
Run Code Online (Sandbox Code Playgroud)
它说:
类型参数不在其范围内
预期:可打包!
发现:Int
我已经测试过它Java
并且它工作正常。