Android project cannot build with gradle after importing a module - android

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.

Related

Manifest Merger Error when adding Vokaturi

I'm making a Mobile and Wear application. However, for the wear build.gradle I'm getting this error:
Error:Execution failed for task ':wear:processDebugManifest'.
Manifest merger failed : Attribute application#theme value=(#android:style/Theme.DeviceDefault) from AndroidManifest.xml:15:9-59
is also present at [:OpenVokaturi-3-0-android:] AndroidManifest.xml:17:9-40 value=(#style/AppTheme).
Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:10:5-36:19 to override.
"
This is the Mobile.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "chun.emotionsensor"
minSdkVersion 25
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(include: ['*.jar'], dir: 'libs')
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'
wearApp project(':wear')
implementation 'com.google.android.gms:play-services-wearable:+'
compile(name: 'OpenVokaturi-3-0-android', ext: 'aar')
implementation 'com.android.support:support-annotations:27.1.1'
}
This is the wear.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "chun.emotionsensor"
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.support:wearable:2.3.0'
implementation 'com.google.android.gms:play-services-wearable:15.0.1'
implementation 'com.android.support:percent:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:wear:26.1.0'
compileOnly 'com.google.android.wearable:wearable:2.3.0'
compile(name: 'OpenVokaturi-3-0-android', ext: 'aar')
}
The OpenVokaturi library that you have included in your build has set a theme value that conflicts with the theme of your application.
It is possible to overrride this conflicting theme by adding the following to your manifest, AndroidManifest.xml, and building your application again:
tools:replace="android:theme"

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'
}

Upgraded to Android Studio 3.0: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :appLib

After upgrading to Android Studio 3.0 gradle snyc fails with the following error messages:
Unable to resolve dependency for
':Skynavigator#debug/compileClasspath': Could not resolve project
:SkyNavLib.
Unable to resolve dependency for
':Skynavigator#debugAndroidTest/compileClasspath': Could not resolve
project :SkyNavLib.
Unable to resolve dependency for
':Skynavigator#debugUnitTest/compileClasspath': Could not resolve
project :SkyNavLib.
Unable to resolve dependency for
':Skynavigator#release/compileClasspath': Could not resolve project
:SkyNavLib.
Unable to resolve dependency for
':Skynavigator#releaseUnitTest/compileClasspath': Could not resolve
project :SkyNavLib.
I already checked all solutions from the following link, but none worked. I also created a new project which also contains a library, and this project syncs without any problem.
Below the used build.gradle files:
For the project:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
for the App:
apply plugin: 'com.android.application'
android {
updateVersionProperties()
compileSdkVersion 26
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode getAndroidVersionCode()
versionName getAndroidVersionName()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions
{
abortOnError false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'net.sf.marineapi:marineapi:0.10.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation files('libs/usbserial.jar')
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 project(':SkyNavLib')
}
for the Library:
apply plugin: 'com.android.application'
allprojects {
buildscript {
repositories {
google()
jcenter()
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
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 files('src/main/java/app/skynavigator/common/skynavlib/xml/gson-2.5.jar')
}
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Your library is using the wrong plugin, it should be apply plugin: 'com.android.library' instead of apply plugin: 'com.android.application'.
Moreover you should not put the allProjects node into this build.gradle file.
new library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
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 files('src/main/java/app/skynavigator/common/skynavlib/xml/gson-2.5.jar')
}

My app is not recognizing a library imported inside another custom library

I am new to android development.
I created a simple custom button library with rounded button that I'm using in another custom library. I used file->import->module->myCustomButtonLibrary to my another custom library.
That custom library is recognizing the button library fine along with all of its functionality.
Now I'm using that another library in the a app. I imported that the library same way, and the app is recognizing all the functionality of the other library but it is unable to access class from the button library.
This is the error I get
Cannot access class 'com.example.CustomButton'. Check your module classpath for missing or conflicting dependencies
Application's build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.screenpatterns"
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(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.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'
implementation project(':screenpattern') }
custom library's build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 27
defaultConfig {
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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 project(':custombutton')
}
repositories {
mavenCentral()
}
As you can see screen pattern library already includes custom button library.
any help is appreciated
Thanks in advance.

Building gradle with cmake

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

Categories

Resources