0

I am trying to create and build an android project with command line tools only (on win7).

so far i succeeded in creating an app and building it with gradle via command line. but i needed to use an external library in my app, named objectbox. after using its classes i am getting gradle error and dont know how to resolve it. i got the debug level messages from gradle with this command:

gradlew assemble --debug

and seems the relevant part that the problem lies starts from this:

01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Detected non-existence of artifact 'com.squareup.okio:okio:1.11.0:okio.jar' in resolver cache

i found the template of resolver cache from a healthy entry like this:

01:15:27.177 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'com.google.code.findbugs:jsr305:3.0.2:jsr305.jar' in resolver cache: C:\Users\User.gradle\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar

and found okio-1.11.0.jar at this path:

C:\Users\User.gradle\caches\modules-2\files-2.1\com.squareup.okio\okio\1.11.0\840897fcd7223a8143f1d9b6f69714e7be34fd50

plus some other relevant dirs and files too.

I made some changes and tests, but no success. please help me find the possible cause and solve this last problem.

and this is the contents of my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.11.+'
    }
}
apply plugin: 'android'

android {
    compileSdkVersion 'android-16'
    buildToolsVersion '26.0.1'

    buildTypes {
        release {
            runProguard false
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
}

//=======================================================

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

buildscript {
    ext.objectboxVersion = '1.0.1' // check for latest version
    repositories {
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
}

//==============

apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
user273084
  • 151
  • 7

1 Answers1

0

seems finally i overcame the problem.

first i created an android gradle project with this command executed in an empty folder:

android create project --gradle --gradle-version 2.3.0 --activity Main --package me_at_gmail_dot_com.myprojectname --target 1 --path .

this is my working build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}
apply plugin: 'android'

android {
    compileSdkVersion 'android-16'
    buildToolsVersion '26.0.1'

    buildTypes {
        release {
            minifyEnabled false
            proguardFile getDefaultProguardFile('proguard-android.txt')
        }
    }
}

/*dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}*/

//===============================================

buildscript {
    ext.objectboxVersion = '1.0.1' // check for latest version
    repositories {
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
}

//=============

apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'

I used android gradle plugin v2.3.0 because seemed it was the highest version available in the defined repository; with v2.3.3 i was getting a vague error, then i went to the repo to see if it actually exists.

also u see i commented out my libs folder, because i was getting an error about a library name conflict, so i guessed it is the cause, and seems there was no need to objectbox jars that i had put there (i had built them beforehand).

another thing: i changed runProguard false to minifyEnabled false (see this: https://stackoverflow.com/a/27387994/2982512)

and this is my gradle-wrapper.properties:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip

i changed only the last line in accordance with android gradle plugin version (see this: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle)

user273084
  • 151
  • 7