- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我的项目有 2 个模块,分别是 app 和 apphelper 作为库。我一直在尝试将 kotlin 与 android 数据绑定(bind)一起使用,但我不明白为什么它在我构建项目时一直向我显示这些错误:
失败:构建失败,出现异常。
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:stagingRuntimeClasspath'.
> Unable to find a matching configuration in project :apphelper:
- Configuration 'debugApiElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=staging}' and found incompatible value 'BuildTypeAttr{name=debug}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
- Configuration 'debugRuntimeElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=staging}' and found incompatible value 'BuildTypeAttr{name=debug}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.
- Configuration 'releaseApiElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=staging}' and found incompatible value 'BuildTypeAttr{name=release}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=staging}' and found incompatible value 'BuildTypeAttr{name=release}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.
当我简单地点击构建按钮时会显示上面的错误日志,如果我点击运行按钮将应用程序安装到设备上会更奇怪:
:app:transformDexArchiveWithDexMergerForDebug
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/PrintFormatPattern;","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/PrintFormatPattern;\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"com.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/PrintFormatPattern;","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:608)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:563)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:545)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:194)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.mergeDexes(DexArchiveMergerCallable.java:66)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:54)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:37)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)","sources":[{}]}
FAILED
:app:buildInfoGeneratorDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/PrintFormatPattern;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 4s
74 actionable tasks: 7 executed, 67 avoided (91%)
我将 kotlin 版本降级为 '1.1.2-2' 以避免 error并且还在 local.properties 中添加了“kotlin.incremental=false”
这是我所有的 build.gradle 文件:
应用模块:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: 'test-environment.gradle'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
applicationId "com.myapp.android"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
versionCode 1
versionName "1.0"
}
dataBinding {
enabled = true
}
dexOptions {
jumboMode = true
}
if (System.getenv("CIRCLE")) {
defaultConfig {
versionCode Integer.parseInt(System.getenv("CIRCLE_BUILD_NUM"))
versionName "1.0." + System.getenv("CIRCLE_BUILD_NUM")
}
} else {
defaultConfig {
versionCode 1
versionName "1.0"
}
}
signingConfigs {
debug {
storeFile file("../myappdebug.keystore")
storePassword "myapprocks"
keyAlias "myapp"
keyPassword "myapprocks"
}
staging {
storeFile file("../myapp_staging.keystore")
storePassword "myapprocks"
keyAlias "myapp"
keyPassword "myapprocks"
}
release {
storeFile rootProject.file('myapp.keystore')
storePassword System.getenv("KEYSTORE_PASS")
keyAlias System.getenv("ALIAS_NAME")
keyPassword System.getenv("ALIAS_PASS")
}
}
buildTypes {
debug {
ext.betaDistributionNotifications = false
signingConfig signingConfigs.debug
applicationIdSuffix ".dev"
minifyEnabled false
shrinkResources false
proguardFile 'proguard-release.cfg'
testProguardFile 'proguard-release.cfg'
manifestPlaceholders = [providerSuffix: ".dev"]
}
staging {
ext.betaDistributionEmailsFilePath = "staging_distribution_emails.txt"
ext.betaDistributionReleaseNotesFilePath = "release_notes.txt"
signingConfig signingConfigs.staging
applicationIdSuffix ".staging"
shrinkResources true
minifyEnabled true
proguardFile 'proguard-release.cfg'
manifestPlaceholders = [providerSuffix: ".staging"]
}
release {
signingConfig signingConfigs.release
shrinkResources true
minifyEnabled true
proguardFile 'proguard-release.cfg'
}
}
}
kapt {
generateStubs = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
api project(':apphelper')
compile 'com.android.support:appcompat-v7:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:cardview-v7:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:design:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:support-v13:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'hanks.xyz:smallbang-library:0.1.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.device.yearclass:yearclass:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "android.arch.lifecycle:runtime:" + project.ANDROID_ARCH_VERSION
compile "android.arch.lifecycle:extensions:" + project.ANDROID_ARCH_VERSION
annotationProcessor "android.arch.lifecycle:compiler:" + project.ANDROID_ARCH_VERSION
compile "android.arch.persistence.room:runtime:" + project.ANDROID_ARCH_VERSION
annotationProcessor "android.arch.persistence.room:compiler:" + project.ANDROID_ARCH_VERSION
kapt "com.android.databinding:compiler:$android_plugin_version"
}
库模块:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.xml'
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.properties'
}
}
kapt {
generateStubs = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.1.0'
compile group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '3.4.1'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'hanks.xyz:smallbang-library:0.1.2'
compile 'com.android.support:support-annotations:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:support-v13:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:appcompat-v7:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:design:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:customtabs:' + project.ANDROID_SUPPORT_LIBRARY_VERSION
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.github.bumptech.glide:glide:3.7.0'
}
repositories {
mavenCentral()
}
主要的 gradle 构建脚本:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-2'
ext.android_plugin_version = '3.0.0-alpha2'
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath "com.android.tools.build:gradle:$android_plugin_version"
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 {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
谁有和我一样的问题,请分享解决方案。谢谢。
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!