I updated android studio and now I am getting the following error while trying to run the app.
Build command failed.
Error while executing process
C:\Users\bhaskar\AppData\Local\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build C:\Users\bhaskar\Desktop\New Projects\otv
2\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target baseUrl}
Unknown argument Projects\otv
Unknown argument 2\app\.externalNativeBuild\cmake\debug\armeabi-v7a
Usage: cmake --build <dir> [options] [-- [native-options]]
I have tried the link but didn't work for me.
Android Studio CMake Error: Build Command failed
My build.gradle file is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.osolutions.otv"
minSdkVersion 16
targetSdkVersion 28
versionCode 9
versionName "1.1.1"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a", "x86"
}
externalNativeBuild {
cmake {
version "3.10.2"
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/YouTubeAndroidPlayerApi.jar')
// retrofit, gson
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
}
I have tried clean and rebuild the project, Invalidate cache and restart, tried steps in the link that I have shared none of it seems to be working for me. Any help would be appreciated.
I solved it by using older version of cmake. I had two versions folder inside path
C:\Users\bhaskar\AppData\Local\Android\sdk\cmake
3.6.41111459 and 3.10.2.4988404. I deleted the 3.10.... folder and run the project and it worked fine.
Related
I have an Android project which has to include a Unity project as well. Without importing the Unity project, I can successfully generated the release build APK (signed APK). But after including Unity project, I am facing this issue:
4 subsequent errors are:
Program type already present: androidx.arch.core.internal.SafeIterableMap$Entry
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: androidx.arch.core.internal.SafeIterableMap$Entry
Error: Program type already present: androidx.arch.core.internal.SafeIterableMap$Entry
Steps I've taken to include the unity project into Android project:
Export the Unity project
Build the exported project as a library
Include the .aar file in the native android project
By native android app level gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "application.package.name"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
externalNativeBuild {
cmake {
// arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
cppFlags "-std=c++11", "-frtti", "-fexceptions"
}
}
ndk {
abiFilters 'armeabi-v7a'/*, 'arm64-v8a'*/
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
// ndkBuild {
// path 'src/main/jni/Android.mk'
// }
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress "tflite"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
configurations {
compile.exclude group: 'androidx.annotation', module: 'annotation'
// added after getting com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes
}
repositories {
maven {
url 'https://google.bintray.com/tensorflow'
}
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'tensorflow-lite', ext: 'aar')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation "android.arch.core:runtime:1.1.1"
implementation "android.arch.core:common:1.1.1"
implementation project(':openCVLibrary341')
// compile 'org.tensorflow:tensorflow-lite:+'
implementation project(':macelibrary')
testImplementation 'junit:junit:4.12'
implementation(project(':unity')){
exclude group: 'androidx.arch.core' // added after reading the below linked question
}
}
Unity Project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
android {
compileSdkVersion 29
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
ndk {
abiFilters 'armeabi-v7a'
}
versionCode 1
versionName '0.1'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb']
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
/*buildTypes {
debug {
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
signingConfig signingConfigs.debug
jniDebuggable true
}
release {
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
signingConfig signingConfigs.debug
}
}*/
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
}
buildTypes {
release {
multiDexEnabled = true
}
}
}
This question is a duplicate of this question, but there is no answer to the original question and I don't have enough reputation to comment and ask about the issue. The only difference is, after reading this question, I removed Firebase from Unity project and tried to generate signed APK, that didn't help either, same error.
Please help me with this issue. Thanks in advance!
Solution:
I managed to solve this issue by removing the androidx.* libraries from the libs directory of the exported unity project.
Reason:
androidx.* libraries were already being included in the native android project. While including the Unity project as library, the library also had all these androidx.* libraries and these were causing this issue.
As it turned out, while exporting a Unity project as native Android project, Unity by default includes these androidx.* libraries. They are only needed if we want to build an APK out of that project. But for building a library out of it, these androidx.* libraries are not required.
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
I am trying to zip an android source using gradle but my gradle task not doing anything. After completing the gradle sync, nothing happening, my source is not zipping.
I followed this but didn't work.
My Gradle :
apply plugin: 'com.android.application'
task myZip(type: Zip) {
from 'src/main/assets/'
include '*/*'
archiveName 'test.zip'
destinationDir(file('src/main/'))
println "Zipping Continues... "
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "test.sample.com.myapplication"
minSdkVersion 15
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
This is my gradle scripts and please suggest me some solution.
I hit the same issue when I wanted to zip the JNI libs with symbols before publishing them to a private maven feed. It took me some time to figure out the steps as I am not familiar with Gradle. Basically, I solved it by adding an extra step to run the myZip task in the build pipeline:
./gradlew build
./gradlew myZip # extra step to run the myZip task
./gradlew publish
Here is part of my build.gradle as for reference:
apply plugin: 'maven-publish'
task myZip(type: Zip) {
archiveName "symbols.zip"
from "$buildDir/intermediates/transforms/mergeJniLibs"
destinationDir file("$buildDir/outputs/sym")
doFirst {
println "Run myZip task to create symbols.zip"
}
}
publishing {
publications {
symbolsPublication(MavenPublication) {
... ...
artifact file("$buildDir/outputs/sym/symbols.zip")
}
}
}
... ...
I can't debug my Java classes or Kotlin files, all breakpoints has "x" signature , but it works for cpp class files
I'm using
Android Studio version 2.2.2
OS version macOS siera 10.12
Gradle version 2.2.2
this is my Module Build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "awesomethings.ge.takeapic"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++11 -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
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'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.github.bumptech.glide:glide:3.7.0'
}
repositories {
mavenCentral()
}
Gradle says it's unable to find 'signingConfig()' method which is used to sign apk.
It also lists possible reasons:
1) The project may be using a version of gradle that doesn't contain it.
2) The build file may be missing a Gradle plugin.
Here's my grade.build:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "happy.blumental.maxim.testproject"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias('releaseKey')
storeFile file('mykeystore.jks')
keyPassword('key')
storePassword('store')
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfigs signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:support-v4:$support_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "io.reactivex:rxjava:1.0.14"
compile('io.reactivex:rxkotlin:0.24.100') { exclude module: 'funktionale' }
compile "io.reactivex:rxandroid:1.0.1"
compile "com.jakewharton.rxbinding:rxbinding-kotlin:0.3.0"
compile 'org.jetbrains.kotlin:kotlin-reflect:1.0.0-beta-1038'
compile 'com.trello:rxlifecycle:0.3.0'
compile 'com.trello:rxlifecycle-components:0.3.0'
compile 'com.parse:parse-android:1.10.2'
}
Properties props = new Properties()
props.load(project.rootProject.file('local.properties').newDataInputStream())
String parseAppId = props.getProperty('parse.app_id') ?: "Specify APP_ID"
String parseClientKey = props.getProperty('parse.client_key') ?: "Specify CLIENT_KEY"
android.buildTypes.each { type ->
type.buildConfigField 'String', 'PARSE_APP_ID', "\"$parseAppId\""
type.buildConfigField 'String', 'PARSE_CLIENT_KEY', "\"$parseClientKey\""
}
I use gradle plugin 1.4.0-beta6.
And here's my error log:
Error:(30, 0) Gradle DSL method not found: 'signingConfigs()'
Possible causes:The project 'TestProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Rename a property in your release buildType from signingConfigs to signingConfig as:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
Take a look at the dsl reference, you've misspelled the property name.