cannot resolve dependencies in Android Studio - android

Im really stuck whit this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.example.testing"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':External-Module')
}
I dont know what to do... I cant build project and use dependencies from External module.
the error is:
Error:(7, 47) error: package com.example.android.transfer does not exist
Error:(19, 9) error: cannot find symbol class ClientData
Error:(19, 25) error: cannot find symbol variable ClientData
Error:Execution failed for task ':Testing:compileDebugJava'.
but inside the IDE all is well and I can see the module
Here is also the External Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.example.externalmodule"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
}

Your "External-Module" is an Android library, so according to the Gradle+Android documentation instead of
apply plugin: 'com.android.application'
it should be
apply plugin: 'com.android.library'
// Old version of the plugin
// apply plugin: 'android-library'
Also, make sure the imports in your app matches the package you are overriding in your library build script. Looks like the app is not founding com.example.android.transfer but the library package really is com.example.externalmodule

Related

Android Resource Linking Failed although i have all the resource files | Kotlin

Error Screenshot
Whenever I run the app in emulator it shows the above error. But I have all the resource files.
App Directory
dependencies showed in screenshot.
Other part of the gradle is:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.modshabuisness"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Did you clean and rebuild project? Would you please check xml selector <?xml version="1.0" encoding="utf-8"?> more than one in your xml file , if had keep it single by removing others.

OpenCV3 error in Camera2Renderer.java [duplicate]

I imported the opencv android library to my android studio and the Camera2Renderer class has a lot of compiler errors because the android.hardware.camera2 classes can't be imported.
I solved the problem. Jim was right, I did not have the correct target API. For the next person who has this problem and finds this thread, the solution is that you have to make sure that the build.gradle files for your project and your OpenCV match.
I am working with openCVLibrary3.2.0 and trying to run its sample and faced same issue but I changed gradle files for both mysampleApp and openCVLibrary320 module as below
This is my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "org.opencv.face"
minSdkVersion 9
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
ndk {
moduleName "native_sample"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
dependencies {
compile project(path: ':openCVLibrary320')
}
and this my OpenCV library module build.gradle file
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Note:
things to notice are that compileSdkVersion, buildToolsVersion, minSdkVersion, and targetSdkVersion these must be same for all gradle files
I changed the compileSdkVersion from 14 to 23
and buildToolsVersion to "23.0.2"
this solved the camera2 import related issue
I am working on openCVLibrary330 trying to run its sample and faced same issue but i changed gradle files for openCVLibrary330 module as below
This is my app build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
I had the same problem. But, as many people have suggested I didn't had to change the gradle files to match exactly the same. I changed my compileSdkVersion and buildToolsVersion to the same on both gradle files, the rest are different. Its working fine now.

Gradle error in Android

Anyone know what I'm missing? My program worked 5 minutes ago and know I have this strange error:
17:16:38 UnsupportedMethodException
Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.: Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I can't ignore it because I can not run it anymore on my android device, anyone?
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:21.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
As I thought, there are many out of date plugins/tools here. Please try this fixed and updated build.gradle:
Also, make sure you are using the latest build plugin: com.android.tools.build:gradle:1.1.3.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- was 21
buildToolsVersion "22.0.1" // <-- was 20.0.0
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 22 // <-- was 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:6.5.87' // <-- was 4.2.42
compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.+
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1' // (the only up to date plugin you had)
}

Android studio importing in gradle issue

I am new to Android Studio and was just trying to import my eclipse project. i am trying to resolve this issue for quite a while now but unable to.
I have a mainactivity project which uses mmany other libraries staggeredgridview, devsmart, google maps and appcompactv7. I am getting following 2 errors.
Note: mainactivity project is the one which i am working on and uses other external libraries.
Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library B:\Android Studio Projects\mainActivity\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage
:mainActivity:processDebugManifest FAILED
Error:Execution failed for task ':mainActivity:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
build.gradle of mainactivity
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':devsmartAndroid')
compile project(':staggeredGridViewmaster')
compile 'com.google.guava:guava:16.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/commons-codec-1.6.jar')
}
build.grade for devsmart
apply plugin: 'com.android.library'
android {
compileSdkVersion 14
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 4
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
build.gradle for sttageredgridview
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
Just edit minsdk of your build.gradle of mainactivity to 9 :
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 9 // changed line
targetSdkVersion 16
}
Note : Also did the same for other libs if there minsdk is small then 9
Please open your manifest file and write the bellow code it will work
<uses-sdk tools:overrideLibrary="com.google.android.gms"/>
and add the list of libraries for uses-skd separated by comma
Go to all the manifest files or build.gradle files of all the projects and make the minSDKversions the same.8 for instance.

Android studio - Build script error, unsupported Gradle DSL method found: 'android()'!

I'm getting the following error in Android Studio 0.4.2 when I'm trying to Sync project with gradle.
Gradle 'GooglePlayServicesTest' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'android()'!
My projects gradle file is as follows :-
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android{
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
sourceSets{
main{
manifest.srcFile 'GooglePlayServicesTest/src/main/AndroidManifest.xml'
}
}
}
gradle file of module:-
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
also I have removed the miniSDKVersion and targetSDKVersion from AndroidManifest.xml
can someone help me to solve this error.
android method in project gradle file is not needed.Try to remove it.
Add top of your project build.gradle file:
apply plugin: 'com.android.application'

Categories

Resources