I have an app and two library modules - moduleA, moduleB.
Both of these modules are using a common jar file "xyz.jar" which is being placed in their respective libs folder.
When i am trying to build this project in Android studio i am getting following error -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have already enabled multi dex by adding following lines in build files-
multiDexEnabled true
api 'com.android.support:multidex:1.0.2'
Could anyone please help? Almost whole day have been gone without any solution.
build.gradle for ModuleA
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.1.jar')
}
build.gradle for ModuleB
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.7.jar')
implementation files('libs/bbdeviceotaapi-android-1.5.2.jar')
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "visa.testapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':moduleA')
implementation project(':moduleB')
}
App Level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties file
#Tue Oct 16 14:44:59 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Build Error Received
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
AGPBI: {"kind":"error","text":"Program type already present: com.bbpos.bb03z.c","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\9.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\11.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\17.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\20.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\22.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\40.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 56s
In Android Studio, Change the View from Android to Project and inside your app >> libs paste your .jar files
Then right click on your .jar file and select Add As Library
It will sync your project and added as gradle dependency
Related
I recently created a library using the File -> new Module -> Android Library, it worked on my app as the module was locally available to the project (same root directory), but when I pushed it to GitHub and published it on JitPack, using the library
implementation 'com.github.okraHQ:okra-android-sdk:v1.0'
I tried implementing it on the same project and a different project and
I got the error
ERROR: Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.github.okraHQ:okra-android-sdk:v1.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.github.okraHQ:okra-android-sdk:v1.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.github.okraHQ:okra-android-sdk:v1.0.
Show Details
Affected Modules: app
What would be the cause of the issue, I have followed other question but found no solution.
Below is the Build gradle of my Library:
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
This is the build gradle for the application that uses the module
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.okra.widget.example"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.github.okraHQ:okra-android-sdk:0.1-alpha'
}
This is the one for the project
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com";
}
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My project includes many modules, and I want to enable static code analyze for some of them. Thus I do following test, but it failed. Below is my library's build.gradle.
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError true
ignoreWarnings false
checkReleaseBuilds true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
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'
}
And below is my app's build.gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.hp.myapplication"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError true
ignoreWarnings false
checkReleaseBuilds true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.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'
compile project(':mylibrary')
}
And I add a lint error in my library, below is mylibrary lint and ./gradlew assembleRelease result
hpdeMac-Pro:MyApplication hp$ ./gradlew mylibrary:lint
> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
> Task :mylibrary:lint
Ran lint on variant release: 2 issues found
Ran lint on variant debug: 2 issues found
Wrote HTML report to file:///Users/hp/Downloads/MyApplication/mylibrary/build/reports/lint-results.html
Wrote XML report to file:///Users/hp/Downloads/MyApplication/mylibrary/build/reports/lint-results.xml
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mylibrary:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
23 actionable tasks: 7 executed, 16 up-to-date
hpdeMac-Pro:MyApplication hp$ ./gradlew assembleRelease
> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
BUILD SUCCESSFUL in 0s
51 actionable tasks: 1 executed, 50 up-to-date
hpdeMac-Pro:MyApplication hp$
Would you like to explain why ./gradlew assembleRelease can't find the lint error and how to enable static code check for modules only? Thanks a lot.
I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail api in my project.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.persi.eatery"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mailcap.default'
exclude 'META-INF/mimetypes.default'
}
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.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'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.sun.mail:android-mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
My library gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
P.S I have already tried Clean project followed by rebuild project as suggested in other answers but its still not working.Thanks in advance
Unable to merge dex
You have a dependencies conflict. Try to see your dependencies via command ./gradlew app:dependencies (Details here ). And you will see the next situation:
As you can see android-mail depends on android-activation. I think you don't need to use the line implementation 'com.sun.mail:android-activation:1.6.1'
P.S. For debugging builds you can use the next flag "--stacktrace". Then you can see more information about your issue.
I'm trying to implement Android Instant Apps Support to my app and I've followed this tutorial:
http://androidkt.com/instant-app/
Everything was going perfect and I've successfully completed the tutorial.
But, I faced this error:
Error:FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':appapk:preDebugBuild'. > Android dependency 'com.android.support:support-v4' has different
version for the compile (25.2.0) and runtime (27.0.1) classpath. You
should manually set the same version via DependencyResolution
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
My project targets the latest version of Android (Android 8.1 API 27) and because of this, all versions should be 27 and above.
I think that this error is because of com.android.support:support-v4 is version 25.2.0 but when I searched my whole project, I was not able to find that com.android.support:support-v4 or any file that is 25.2.0.
Here are my gradle files if necessary:
build.gradle (Project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
maven { url 'https://jitpack.io' }
}
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (module: app-base):
apply plugin: 'com.android.feature'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
baseFeature = true
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
multiDexEnabled true
versionCode 3
versionName "2.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation 'com.android.support:support-v4:27.0.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//compile 'android-support-v7-appcompat:25.0.1'
implementation 'com.github.HITGIF:TextFieldBoxes:1.3.8'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.android.support:design:24.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:cardview-v7:24.2.1'
implementation 'com.android.support:customtabs:27.0.2'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (module: appapk):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "tr.k12.evrim.evrimnews.app"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':app-base')
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.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'
}
build.gradle (module: instantapp):
apply plugin: 'com.android.instantapp'
android {
buildToolsVersion "26.0.2"
}
dependencies {
implementation project(':app-base')
}
With reference to google issue Tracker we were able to reproduce the issue in app with the same setup as in your build.gradle files.
The app can be successfully compiled when changing the com.android.support:support-v4 dependency in base from implementation to api and updating com.android.support:appcompat-v7:27.0.1 to 27.0.2.
The difference between implementation and api is that
implementation does not expose the dependency to other modules that depend on it, including libraries that need to be sync’d to the higher version (in this case, 25.x.x to 27).
While api dependencies will be exposed to all consumers of the library.
This question already has answers here:
Unable to merge dex error [duplicate]
(2 answers)
Closed 5 years ago.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I am using version 3.0.1 of Android Studio.
I also tried 'clean project' and 'rebuild project'.
*project build gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
*module build gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
ext {
grpcVersion = '1.4.0'
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.backkom.speechtest"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.3.0'
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.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'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// gRPC
compile "io.grpc:grpc-okhttp:$grpcVersion"
compile "io.grpc:grpc-protobuf-lite:$grpcVersion"
compile "io.grpc:grpc-stub:$grpcVersion"
compile 'javax.annotation:javax.annotation-api:1.2'
protobuf 'com.google.protobuf:protobuf-java:3.3.1'
compile group: 'com.google.api.grpc', name: 'grpc-google-cloud-speech-v1', version: '0.1.13'
// OAuth2 for Google API
compile('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
exclude module: 'httpclient'
}
compile 'com.android.support:multidex:1.0.2'
}
When I do a rebuild project, I get an error like below.
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [C:\Users\backkom\AndroidStudioProjects\SpeechTest\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\backkom.gradle\caches\modules-2\files-2.1\com.google.protobuf\protobuf-java\3.3.1\e8964a2667e55d11a4505b329a4c34247663920b\protobuf-java-3.3.1.jar(;;;;;;**.class)] (Duplicate zip entry [protobuf-java-3.3.1.jar:com/google/protobuf/ExperimentalApi.class]))
From your error log it seems like your directory backkom is not available for android studio . so please check your directory
C:\Users\backkom
is writable or not . by doing so . go to that directory and check its permission . is it has read and write both permission or not .
As per my understanding,
Try this :
Clean Project button.
Rebuild Project button from the Build menu.
And change your local.properties with this
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
And define gradle in this way
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 21
targetSdkVersion 26
versionCode 7
versionName "0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
And add this multidex in your project
compile 'com.android.support:multidex:1.0.1'
and Define it in Manifest