Building gradle with cmake - android

I'm getting the error "Unable to get the CMake version located at C:\Users\Mujtaba Faizi\Downloads\cmake-3.10.1\bin" but I gave the version 3.10.1 in build.gradle and the path in local.properties. I've been at it for so long. Thanks in advance.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.mujtaba.basicai"
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'
}
}
sourceSets {
main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/', 'src/main/jniLibs/armeabi-v7a'] }
}
externalNativeBuild {
cmake {
version "3.10.1"
path 'CMakeLists.txt'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design: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 files('libs/libandroid_tensorflow_inference_java.jar')
compile 'com.flurgle:camerakit:0.9.13' //for camera access purposes
}
local.properties:
cmake.dir=C\:\\Users\\Mujtaba Faizi\\Downloads\\cmake-3.10.1
ndk.dir=C\:\\Users\\Mujtaba Faizi\\AppData\\Local\\Android\\Sdk\\ndk-bundle
sdk.dir=C\:\\Users\\Mujtaba Faizi\\AppData\\Local\\Android\\Sdk

This thread is kind of old. But in my case I did not added cmake version to gradle file instead I just had to add path to local.properties
cmake.dir=/home/rafal/Pobrane/cmake-3.11.0

Related

Unable to include dependence library when export aar file

I created a module and now I am trying to export the .aar file but I cannot include the gradle dependencies I used in the module to the .aar file. I tried the solution of this post with no success. Here is how my app level .build file looks like:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation ('com.daimajia.androidanimations:library:2.3#aar')
{transitive=true}
implementation ('com.google.android.exoplayer:exoplayer-core:2.10.0')
{transitive=true}
implementation ('tyrantgit:explosionfield:1.0.1')
{transitive=true}
}
What am I missing?

How to resolve dependency for ':app#releaseUnitTest/compileClasspath'

Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
defaultConfig {
applicationId "com.example.usman.testing"
minSdkVersion 15
targetSdkVersion 29
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:29.+'
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'
}

Android project cannot build with gradle after importing a module

I created an android app and I wanted to include the vokaturi module. I changed the vokaturi.gradle file with "com.android.library" and I included ":vokaturi" module in the settings.gradle file and in the main app module I added implementation project(':vokaturi') When I try to syncronised main app module I get the error
Could not find :OpenVokaturi-Android:.
Required by:
project :app > project :vokaturi
Search in build.gradle files
This is how my main app.gradle file looks like.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.afinity"
minSdkVersion 21
targetSdkVersion 28
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(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(':vokaturi')
}
And this is how the vokaturi.gradle file looks like
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'
}
}
}
repositories {
flatDir {
dirs 'libs/aars'
}
}
dependencies {
implementation(name: 'OpenVokaturi-Android', ext: 'aar')
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.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
I do not know what I do wrong...I am new at android, thank you all for any help
The default name of the file is probably - OpenVokaturi-3-0-android.aar and not OpenVokaturi-Android which is why you're getting that error. Also this -
implementation(name: 'OpenVokaturi-3-0-android.aar', ext: 'aar')
should not be in your vokaturi module but rather in your app.gradle file. Add that line to your app gradle file and then include vokaturi directly as an aar file.

Can't start a new project because of gradle error

I created a new project as usual andafter the gradle running I get this error:
`Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.`
This is my fresh project gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.elili.deltacalculator"
minSdkVersion 18
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'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
I have zero ideas on how to fix it...
If you are not going to implement testing code, then remove junit from your app. You can replace your gradle by below.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.elili.deltacalculator"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
You need to try the annotation library using:
androidTestCompile 'com.android.support:support-annotations:26.1.0'
First way, It use like this:
Force to use support annotations in the test app, so it is internally used by the runner module.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
.
.
.
.
androidTestCompile 'com.android.support:support-annotations:26.1.0'
}
Second way is to use this as:
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}

android CMake can not determine linker language for target

I have created a very simple project about android and c++ in android studio.
the struct of project(module) is like:
enter image description here
And build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.shuyi.study.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"a
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
}
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'
implementation 'com.android.support:design: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'
}
when I start Gradle sync, it logged the informations:
enter image description here
I can not find the reason of this error.
Pleas give me some ides.Thanks!!!

Categories

Resources