在更新到Android Studio 3.0并创建一个新项目后,我注意到build.gradle
有一种新方法可以添加新的依赖项,而不是compile
存在implementation
而不是testCompile
存在testImplementation
.
例:
implementation 'com.android.support:appcompat-v7:25.0.0'
testImplementation 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)
代替
compile 'com.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'
Run Code Online (Sandbox Code Playgroud)
它们之间有什么区别,我应该使用什么?
dependency-management gradle transitive-dependency build.gradle gradle-plugin
更新到android studio 2.3后,我收到此错误消息.我知道这只是一个暗示,因为应用程序正常运行,但它真的很奇怪.
所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到的版本25.1.1,24.0.0.示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0
我的朋友:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.blankj:utilcode:1.3.6'
compile 'com.orhanobut:logger:1.15'
compile 'com.facebook.stetho:stetho:1.4.2'
provided 'com.google.auto.value:auto-value:1.2'
annotationProcessor 'com.google.auto.value:auto-value:1.2'
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
compile 'com.mikepenz:iconics-core:2.8.2@aar'
compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile 'com.github.GrenderG:Toasty:1.1.1'
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
compile 'com.github.MAXDeliveryNG:slideview:1.0.0'
compile 'com.facebook.fresco:fresco:1.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.maps.android:android-maps-utils:0.4.4' …
Run Code Online (Sandbox Code Playgroud) 我在Android Studio 2.2 Preview 1中使用Android App和Backend模块在Google Messaging中创建了一个新项目.这是应用程序文件:
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'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
Run Code Online (Sandbox Code Playgroud)
但它给了:
错误:与依赖项'com.google.code.findbugs:jsr305'冲突.app(1.3.9)和测试app(2.0.1)的已解决版本有所不同.有关详细信息,请参阅http://g.co/androidstudio/app-test-app-conflict.
我是Android的新手,无法找到这个错误.我如何解决它?
gradle google-cloud-messaging android-studio build.gradle android-gradle-plugin
如何在Android Studio 2.0 Preview中禁用Instant Run.当我进入设置时,我看到它:
我无法从"启用即时运行..."中删除勾号
我使用的是Android Studio 2.0 Preview 9,但Android Studio 2.0 Preview 7中也存在此错误.
settings android android-studio instant-run android-instant-run
我试图在控制台输出中调查项目构建错误,如下所示:
:myapp:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
...
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run Code Online (Sandbox Code Playgroud)
我怀疑它与资源未找到错误有关.我的问题是,在IDE级别,我如何添加--stacktrace
或--debug
选项,以便它可以为我调试生成更多信息?
我的gradle项目使用该application
插件来构建一个jar文件.作为运行时传递依赖的一部分,我最终会进入org.slf4j:slf4j-log4j12
.(它被引用为至少5或6个其他传递依赖的子传递依赖 - 这个项目使用spring和hadoop,所以除了厨房水槽之外的所有东西都被拉进来......没等了......那也是:) ).
我想slf4j-log4j12
从我的内置jar中全局排除jar.所以我试过这个:
configurations {
runtime.exclude group: "org.slf4j", name: "slf4j-log4j12"
}
Run Code Online (Sandbox Code Playgroud)
但是,这似乎排除了所有 org.slf4j
工件,包括slf4j-api
.在调试模式下运行时,我看到以下行:
org.slf4j#slf4j-api is excluded from com.pivotal.gfxd:gfxd-demo-mapreduce:1.0(runtime).
org.slf4j#slf4j-simple is excluded from com.pivotal.gfxd:gfxd-demo-mapreduce:1.0(runtime).
org.slf4j#slf4j-log4j12 is excluded from org.apache.hadoop:hadoop-common:2.2.0(runtime).
Run Code Online (Sandbox Code Playgroud)
我不想查找每个slf4j-log4j12
传递依赖的源,然后compile foo { exclude slf4j... }
在我的dependencies
块中有单独的语句.
更新:
我也试过这个:
configurations {
runtime.exclude name: "slf4j-log4j12"
}
Run Code Online (Sandbox Code Playgroud)
最终排除了构建中的所有内容!好像我指定的那样group: "*"
.
更新2:
我正在使用Gradle版本1.10.
当我在稳定通道中将Android Studio更新为3.0并运行项目时,我开始收到以下错误.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Run Code Online (Sandbox Code Playgroud)
我试过清理和重建项目,但它没有用.任何帮助将不胜感激.
项目级build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
应用程序级build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.med.app"
minSdkVersion 21
targetSdkVersion 26 …
Run Code Online (Sandbox Code Playgroud) 我想禁用即时运行,但菜单点不存在。我知道即时运行应该在哪里,但是完全丢失了。我不知道为什么 我刚刚升级到Android Studio 3.5,但是使用AsyncTask时出现错误,并且我知道在禁用即时运行时可以解决该问题,但是我不能。
这是我的礼物(应用程式)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.project.myapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 13
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
resValue "string", "google_maps_api_key", GoogleMapDebug
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/asset/'] } }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2' …
Run Code Online (Sandbox Code Playgroud) 刚刚更新了android studio从2.3.3到3.0现在我有错误
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Run Code Online (Sandbox Code Playgroud)
这是我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "d91.compassacademy"
minSdkVersion 19
targetSdkVersion 25
versionCode 3
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
repositories {
mavenCentral()
google()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.2'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile …
Run Code Online (Sandbox Code Playgroud) 运行命令"ionic cordova build android --stacktrace"时出现以下错误:
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
FAILED
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
I am using following tools on Window's:
Editor : VScode
Ionic: C:\Users\xyz>ionic -version
3.19.1
Npm as packagemanager
Run Code Online (Sandbox Code Playgroud)
项目属性:
target=android-26
cordova.system.library.1=com.google.android.gms:play-services-analytics:+
cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+
cordova.gradle.include.1=cordova-plugin-appsflyer-sdk/customerapp-cordovaAF.gradle
cordova.gradle.include.2=twitter-connect-plugin/customerapp-twitter.gradle
cordova.system.library.3=com.android.support:support-v4:26.+
cordova.system.library.4=com.android.support:appcompat-v7:26.+
cordova.system.library.5=com.android.support:support-v4:24.1.1+
cordova.system.library.6=com.android.support:support-v4:+
android.library.reference.1=CordovaLib
Run Code Online (Sandbox Code Playgroud) 我试图在我的手机上运行我的应用程序,但在build
时间失败时出现以下错误:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
Run Code Online (Sandbox Code Playgroud)
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
到目前为止我尝试过但无济于事: - >清理并重建(重建失败) - >删除./gradle
文件和所有项目构建和缓存文件,然后缓存失效
我的项目gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
google() …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目.这适用于Android studio 2.3.3,但是当我更新我的Android Studio 3.0并打开我的项目然后它无法组装并且它发送给我下面的错误日志时会发生什么.
错误日志
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;
Error:com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;
Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error: at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;
Run Code Online (Sandbox Code Playgroud)
请不要重复,因为我已经尝试过以下所有的事情
有这种通过电子邮件创建报告异常库我。它可以与Android Java项目一起很好地工作,但不能与Android Kotlin一起工作。当我为库添加编译脚本(compile 'com.theah64.bugmailer:bugmailer:1.1.9')
并尝试构建APK时,出现以下错误。
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序的build.gradle文件
应用插件:“ com.android.application” 应用插件:“ kotlin-android” 应用插件:“ kotlin-android-extensions” android { compileSdkVersion 27 defaultConfig { applicationId“ com.theapache64.calculator” minSdkVersion 15 targetSdkVersion 27 版本代码1 versionName“ 1.0” testInstrumentationRunner“ android.support.test.runner.AndroidJUnitRunner” multiDexEnabled是 } buildTypes { 发布 { minifyEnabled false multiDexEnabled是 proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro' } } dexOptions { preDexLibraries =否 javaMaxHeapSize“ 4g” } } 依赖项{ 实现fileTree(dir:'libs',包括:['* .jar']) 实现“ org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version” 实施'com.android.support:appcompat-v7:27.0.2' 实现'com.android.support.constraint:constraint-layout:1.0.2' 实现'com.android.support:design:27.0.2' testImplementation'junit:junit:4.12' androidTestImplementation'com.android.support.test:runner:1.0.1' androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1' 编译'com.theah64.bugmailer:bugmailer:1.2.0' }
我在Google上搜索了很多,并尝试了multiDexEnabled …
android ×10
gradle ×6
build.gradle ×3
java ×3
kotlin ×2
apache ×1
cordova ×1
dex ×1
instant-run ×1
ionic3 ×1
settings ×1
stack-trace ×1