Gradle cannot find target sdk - android

I need to write a small library with submodules. When i try sync my project i get error.
if i use gradle gradle:1.0.1
Error:Configuration with name 'default' not found.
if build:gradle:1.2.3
Error:Cause: failed to find target 21
but this sdk already installed.
Here is my build.gradle
uildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':libs:UniversalImageLoader')
}
project(':libs:UniversalImageLoader') {
apply plugin: 'com.android.library'
android.compileSdkVersion = 21
android.buildToolsVersion = "21.1.2"
android.sourceSets.main {
manifest.srcFile 'library/AndroidManifest.xml'
java.srcDirs = ['library/src']
res.srcDirs = ['library/res']
}
}
Any ideas on this subject? Thx for help.

Related

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. not solving

I have possibly tried all the solutions regarding this issue.
The full error is: Error:Execution failed for task "
':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
"
I am posting my build.gradle scripts:
Script name: RajawaliCardBoardExample-master
// 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.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
name: Module:app >>
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "4g"
jumboMode = true
}
defaultConfig {
applicationId "com.eje_c.rajawalicardboard"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':rajawalicardboard')
compile project(':lib_panorama_max')
compile 'com.android.support:multidex:1.0.1'
}
name: Module:lib_panorama_max >>
apply plugin: 'java'
task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
options.encoding = "UTF-8"
options.debug = true
options.debugOptions.debugLevel = "source,lines,vars"
options.encoding = "UTF-8"
}
dependencies {
compile files('libs/commons-httpclient-3.1.jar')
compile files('libs/android.jar')
compile fileTree(dir: 'build/native-libs', include: ['*.jar'])
}
name: Module:Rajawali >>
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
name: Module:rajawalicardboard >>
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':rajawali')
}
Please help to sort it out! :(
At first you should add
defaultConfig
{
// Enabling multidex support.
multiDexEnabled true
}
Open Module:app .You missing multiDexEnabled true in here .
defaultConfig {
applicationId "com.eje_c.rajawalicardboard"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
Read Official Document about MultiDex
The option 1 was adding multiDexEnabled true
But you told it didn't work at all, you can try excluding group group: 'com.android.support', module: 'multidex' now which means in the compilation for example change
compile project(':rajawalicardboard')
To
compile project(':rajawalicardboard'){
exclude group: 'com.android.support', module: 'multidex'
}
Don't only try on this, do the same in compile project(':lib_panorama_max') if only the changes above didn't work. Try removing compile 'com.android.support:multidex:1.0.1' too.

Plugin not found when importing project as library in Android Studio

I am trying to integrate an application to another one. To do that I compiled the first one as a library and after that I added it to the dependencies of the application project after I added it as a module following some guides in stackoverflow.
The problem is that after doing that, I got an error about a missing plugin. Although I have researched a bit over google I have had no luck on that one.
The error is Error:(4, 0) Plugin with id 'com.google.protobuf' not found.
Open File
Both applications work very well, each on their own... What am I doing wrong ?
Here is my build graddle of the main app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.arlind.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Here is the build graddle of the added library
import java.text.SimpleDateFormat
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
android {
signingConfigs {
global {
keyAlias "Lind"
keyPassword "gators"
storeFile file("lindkey.keystore")
storePassword "gators"
}
}
compileSdkVersion 22
buildToolsVersion "23.0.0"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.global
}
}
productFlavors {
catapult {
versionCode getLongDate().toInteger()
versionName '12.1-' + getShortDate()
}
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(path: ':wallpaperPicker')
}
sourceSets {
main {
manifest.srcFile '../AndroidManifest.xml'
java.srcDirs = ['../src', '../util', '../extra/src']
res.srcDirs = ['../res', '../extra/res']
proto {
srcDir '../protos'
}
}
}
}
def getDate(String dateFormat) {
def df = new SimpleDateFormat(dateFormat)
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
df.setTimeZone(tz)
return df.format(new Date())
}
def getLongDate() {
return getDate("yyMMddHH")
}
def getShortDate() {
return getDate("yyMMdd")
}

Gradle DSL method not found: 'applicationId()'

I am getting this error on building the application in Android Studio.
Gradle DSL method not found: 'applicationId()'
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
applicationId "com.ms.knowursensor.android"
minSdkVersion 13
defaultConfig {
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "sensorgraph"
stl "c++_static"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
debuggable = true
}
}
debug {
debuggable true
jniDebuggable true
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/jniLibs'
// use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
This issue came when i recently update the SDK. How to resolve this issue?
Move applicationId and minSdkVersion into your defaultConfig closure.

error: duplicate class: android.support.v7.appcompat.R

When I try to compile my project I get this error message "Error:(9, 14) error: duplicate class: android.support.v7.appcompat.R". I'm using android studio and I have the latest SDK packages.
gradle for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile files('libs/commons-codec-1.10.jar')
compile "com.android.support:appcompat-v7:22.0.0"
}
Gradle file for the Project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
these are my gradle files for the project
Move "compileOptions" outside of your "defaultConfig".
I also updated your "buildToolsVersion".
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions { // <-- Moved this outside of your defaultConfig
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('libs/commons-codec-1.10.jar')
compile 'com.android.support:appcompat-v7:22.0.0' // <-- brings in support-v4
}

Robospock and gradle build variants?

I'm using Robospock to perform unit testing and mocking with gradle. This worked great until I added gradle build variants to the mix.
My android build.gradle file:
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "0.0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
uat {
packageName "com.acme.dev"
}
stage {
packageName "com.acme.staging"
}
prod {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.mcxiaoke.volley:library:1.0.4'
}
My robospock build.gradle file:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'org.robospock:robospock-plugin:0.4.0'
}
}
repositories {
mavenCentral()
}
apply plugin: 'groovy'
dependencies {
compile "org.codehaus.groovy:groovy-all:1.8.6"
compile 'org.robospock:robospock:0.4.4'
compile 'cglib:cglib-nodep:2.2'
compile 'org.objenesis:objenesis:1.3'
}
project.ext {
robospock = ":Mothership" // project to test
}
apply plugin: 'robospock'
The Android gradle plug-in offers me build variant tasks such as assembleProd, assembleProdDebug, assembleStageDebugTest. Can I pass something to Robospocl in my build.gradle so that it can participate in the build variants?
Currently when I execute ./gradlew robospok, it cannot find the classes defined in com.acme.dev or com.acme.staging

Categories

Resources