I am trying to learn android in android studio.Now i imported an eclipse project in android studio and now while trying to run it it is not building.Some problems in gradle may be..
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.practise"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:gridlayout-v7:+'
}
Can anyone help me to find out the problem??
Change your dependencies
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
}
Using the +, you are getting the last release.
Currently the last release is the compile 'com.android.support:support-v4:21 and it has a minSdk='L' because it is a preview release.
Use it only to test the android 'L' preview.
Try editing the following line to your Android Manifest file, like so:
dependencies {
compile 'com.android.support:support-v4:21+'
}
Then your project should build.
Change your dependencies in app/build.gradle to lower version
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.eusecom.snowsmsden"
minSdkVersion 16
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.android.support:appcompat-v7:20.+'
}
Related
I recently (3 days ago) started learning Android Studio. I bought an Eclipse game project to play with, but I am getting errors. And when I fix that error, I get a new error.
The current one that I can't seem to fix is:
Error:(2, 0) Could not find method defaultConfig() for arguments
[build_2ttwbw07u5v666j5nx2ciclk3$_run_closure1#5ac759e5] on project
':app' of type org.gradle.api.Project. Open
File
My build.gradle (Module: App):
defaultConfig {
applicationId "com.getemplate.catadventure"
minSdkVersion 14
targetSdkVersion 26
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
Anyone know why I am getting the error?
Here's a screenshot:
Thank you very much for your time and assistance in this matter.
This is because you didn't add code for android application plugin which is apply plugin: 'com.android.application'. You also need to move the defaultConfig inside the android like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
...
}
}
dependencies {
...
}
I have an an Android Studio project A which is an app, and a project B which is a library project. I have included project B in project A. Project B has some dependencies (android async http, and org.json) that are used in both project B and project A. I upgraded Android Studio to 2.2 Preview 2, and am now having an issue where all of my usages of android async http are saying Cannot Resolve Symbol. However, my JSON usages are just fine. When I build the project, I get no errors and can run it just fine. How can I fix the Cannot Resolve Symbol issue in Android Studio?
I have tried
cleaning & rebuilding both projects
making a change in the app's build.gradle & syncing grade
re-arranging the order of dependencies
sync project with gradle files
delete android async http.xml from .idea/libraries & sync project with gradle files
opening and closing android studio
setting minifyEnabled=true in the app & library
Is there something I am missing?
app > build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 33
versionName "2.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile project(':mylibrary')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3'
}
library > build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 2
versionName "1.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile files('libs/org.json-20120521.jar')
compile files('libs/android-async-http-1.4.5.jar')
}
I want to use OpenCV4Android in Android Studio. I downloaded OpenCV for Android from this link:
http://opencv.org/downloads.html
But, when I try to import it, I get different errors in Camera2Renderer.java like, Cannot resolve symbol 'camera2', Cannot resolve symbol 'CameraDevice', Cannot resolve symbol 'Size', and Cannot resolve symbol 'CaptureRequest'.
I have tried both methods available here:
OpenCV in Android Studio
http://answers.opencv.org/question/14546/how-to-work-with-opencv4android-in-android-studio/
But, I get the same error.
Can anyone please tell me how to solve this error to be able to use openCV?
Thank you.
I faced the same issue while configuring OpenCV SDK with Android Studio.
I am using the latest SDK build of OpenCV : OpenCV-3.1.0-android-sdk
Please ensure that you have configured your build.gradle scripts.
Build.gradle(Module: app) -->
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.dev.opencvapp"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLib/'] } }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile project(':openCVLibrary310')
}
Build.gradle(Module: openCVLibrary310) -->
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
After doing this you should be able to build the app with out any errors.
I hope I helped you!!
I know this sounds very easy, but android studio is eating my brains out. I know how to import my current project say myProject in to ADT very easily. But I came to know that soon the support for adt will be ending. So i decided to switch to Android studio. I am using the following libraries in my project
Commons
ActionBarSherlock
AndroidImageChacheMaster
SlidingMenuMaster
I tried to import the project myProject.
See its Project.Properties file
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-21
android.library.reference.1=../actionbarsherlocklibrary
android.library.reference.2=../Android-Image-Cache-master
android.library.reference.3=../Commons
android.library.reference.4=../google-play-services_lib
android.library.reference.5=../SlidingMenuMaster
When i tried to import it A.S told me unrecoverable errors and I pasted the library folder as instructed by android studio.
And it project was imported succesfully
but there are two error apparing in the log
/home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/manifests/tmp/manifestMerger2026412193483179673.xml
Error:(5, 5) uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml
Error:(5, 5) Execution failed for task ':commenorkingandroid:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.actionbarsherlock" to force usage
please help what is wrong here?
and now my project structure is
actionbarsherlocklibrary(empty)
myProject(manifests,java,res,aidl,resources,c,assets)
androidimagecachemaster(manifests,java,res)
commenorkingandroid(manifests,java,res) // i havent imported anything with this name
commons(manifests,java,res)
Gradle Scripts
build.gradle(Project:myProject)
build.gradle(Module:actionbarsherlock)
build.gradle(Module:myProject)
build.gradle(Module:commons)
build.gradle(Module:androidimagecachemaster)
build.gradle(Module:commenorkingandroid)
gradle-wrapper.properties
settings.gradle
here are my gradle files
build.gradle(Project:myProject)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle(Module:actionbarsherlock)
apply plugin: 'java'
build.gradle(Module:myProject)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.five.myApp"
minSdkVersion 11
targetSdkVersion 16
ndk {
moduleName "cr3engine-3-1-1"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':actionbarsherlocklibrary')
compile project(':androidImageCachemaster')
compile project(':commons')
compile project(':commenorkingandroid')
compile 'com.google.code.gson:gson:2.1'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-io-2.4.jar')
compile files('libs/epublib-core-latest.jar')
compile files('libs/slf4j-android-1.6.1-RC1.jar')
compile files('libs/slf4j-android-1.7.5-7-sources.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/zip4j_1.3.2.jar')
}
build.gradle(Module:commons)
apply plugin: 'com.android.library'
android {
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/actionbarsherlock-plugin-maps-4.1.0.jar')
}
build.gradle(Module:androidimagecachemaster)
apply plugin: 'com.android.library'
android {
compileSdkVersion 10
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/CWAC-AdapterWrapper.jar')
}
build.gradle(Module:commenorkingandroid)
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 5
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
}
If you have added Sherlock as an AAR dep like
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
you can remove
compile project(':actionbarsherlocklibrary'), include ':sherlock' line from your settings.gradle, then related folder from your project.
And your targetSdkVersion can be the same as your compileSdkVersion as well.
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.