Tag: android gradle

转换Android项目使用Gradle脚本Kotlin

我想将我的Android项目中的build.gradle文件从Groovy转换为使用Gradle脚本Kotlin的Kotlin 。 最好我希望他们都在Kotlin,但是如果有一些限制,那么尽可能多。 让我们假设我刚刚从Android Studio“新应用程序”模板创建了一个空项目( minSdkVersion 15 ,使用AppCompat)。 我需要采取哪些步骤来将此类项目转换为Gradle Script Kotlin。 我希望这对我(和其他人)来说应该是一个很好的起点,我可以处理转换我自己拥有的任何自定义逻辑。

在Android Studio Canary中将Kotlin还原为Java代码5

我正在用Java编写一个Android应用程序,就像其他人一样。 自从Android Studio 3.o Canary发布并加入对Kotlin的支持后,我有机会尝试一下。 下载插件并正确设置Gradle文件。 但一旦活动转换成Kotlin并同步,就会发生错误。 下面是我的build.gradle, apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' 和, ext.kotlin_version = '1.1.3' 依赖性, 所以,我想回到Java,直到问题解决。 Kotlin代码是, class Welcome : AppCompatActivity() { internal var rujuk = FirebaseDatabase.getInstance().reference /*3rd step, DB reference*/ /*4th, initially write under onStart method, then CnP here, value inside child() should be same as in […]

Kotlin版本1.1.4-eap-77不起作用

我在Kotlin开始了一个新的应用程序,但是当Android Studio完成了新的项目的构建等。是说cand下载正确版本的Kotlin: 这里是构建gradle: // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.4-eap-77' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { […]

在Android Studio Kotlin单元测试

我正在使用Android Studio RC2。 当我尝试通过android studio运行kotlin单元测试时,gradle执行assemblendbug任务并在运行测试之前创建一个debug apk。 使用Java单元测试,它不会这样做。 有没有解决方法? Kotlin单元测试很慢,需要一分钟才能设置和擦除。 谢谢

错误:与依赖项冲突com.google.code.findbugs:jsr305'

我在Android Studio 2.2预览版1中使用Android应用程序和使用Google消息传递的后端模块创建了一个新项目。 这是应用程序文件 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.xxx.xxx" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' compile 'com.google.android.gms:play-services-gcm:9.0.0' testCompile 'junit:junit:4.12' […]

未解决的参考:kotlinx – Kotlin 1-0-0-RC-1036

我正在一个Android应用程序工作,前几天我更新了我的Kotlin版本从1.0.0-beta-1103到候选版本1.0.0-rc-1036 ,现在我无法运行我的应用程序Kotlin Android扩展。 我使用apply plugin: 'kotlin-android-extensions'就像官方博客所说: http apply plugin: 'kotlin-android-extensions'我的应用程序不能识别任何布局的任何视图。 这是在控制台上显示的内容: 错误:(20,8)未解决的参考:kotlinx 错误:执行任务':app:compileDebugKotlin'失败。 编译错误。 查看日志了解更多详情 请帮助我,我正在失去理智! 更新: 这是我在全球build.gradle buildscript { ext { kotlin_version = "1.0.0-rc-1036" } repositories { jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // The Fabric Gradle plugin uses an open ended version to react // quickly […]

在新的Android Studio项目中配置Kotlin

我已经安装了kotlin插件,并在studio中创建了一个新项目。 我去过工具> Kotlin>在项目中配置Kotlin,并遵循所有的步骤,但我的gradle构建不起作用。 我得到这个错误: Error:(24, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed. 打开文件 有人能告诉我什么是错的,或者告诉我为kotlin安装android studio的正确方法。 谢谢。

什么是Kotlin Gradle依赖关系中的“实现”?

我正在使用Android Studio 3.0 Preview来启动新的Kotlin项目。 当我尝试在build.gradle添加依赖项时,我看到了implementation范围,而不是通常的compile 。 androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation 'com.android.support:appcompat-v7:25.3.1' testImplementation 'junit:junit:4.12' 还有androidTestImplementation和testImplementation作用域。 最后,我添加compile添加第三方依赖关系,它的工作原理。 compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 所以我的问题是.. 什么是implementation , androidTestImplementation和testImplementation范围? 它与compile ,测试compile和androidTestCompile有什么不同吗? 我应该为我的Kotlin项目使用哪一个? 编辑:我的不好,这个问题不是Kotlin特定的。 这是新的Android Gradle插件配置 。

Kotlin配置错误

我已经开始在Android的Kotlin编程。我在android studio中设置kotlin。但是gradle无法构建项目。 Kotlin反射lib错误。 这是我的Logcat: 信息:Gradle tasks [:app:assembleDebug]错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理C:\ Users \ USER.gradle \ wrapper \ dists \ gradle-4.1-all \ gradle-4.1 \ caches \ kimlin-reflect-1.1.4 \ 27053164a2b459671c4b9fe791408a5bc064937f \ kotlin-reflect-1.1.4.jar错误:com.android.builder.dexing.DexArchiveBuilderException:dexing时出错。 错误:java.util.NoSuchElementException错误:任务':app:transformClassesWithDexBuilderForDebug'的执行失败。 com.android.build.api.transform.TransformException:com.android.builder.dexing.DexArchiveBuilderException:com.android.builder.dexing.DexArchiveBuilderException:无法处理C:\ Users \ USER.gradle \ wrapper \ dists \ gradle- 4.1-all \ gradle-4.1 \ caches \ modules-2 \ files-2.1 \ org.jetbrains.kotlin \ kotlin-reflect \ 1.1.4 \ 27053164a2b459671c4b9fe791408a5bc064937f \ […]