I want to use both evant/gradle-retrolambda and RoboBinding/RoboBinding in my android project.
When adding RoboBinding to your project, you can choose to use it with AspectJ using RoboBinding/RoboBinding-aspectj-plugin. However, whenever I turn it on, the lambda expressions in my code produce this compile error:
Error:error at (no source information available)
/mnt/FCEE58DAEE588F30/AndroidstudioProjects/SpeechACall/app/src/main/java/com/voicesense/personality_profiling_dialer/GcmRegistrationHandler.java:1:0::0 The type java.lang.invoke.MethodHandles cannot be resolved. It is indirectly referenced from required .class files
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAspectJ'.
> The type java.lang.invoke.MethodHandles cannot be resolved. It is indirectly referenced from required .class files
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
This is my build.gradle file
buildscript {
repositories {
mavenCentral()
maven() {
name 'RoboBinding AspectJPlugin Maven Repository'
url "https://github.com/RoboBinding/RoboBinding-aspectj-plugin/raw/master/mavenRepo"
}
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:2.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
classpath 'org.robobinding:aspectj-plugin:0.8.+'
}
}
repositories {
mavenCentral()
}
apply plugin: 'retrolambda'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'org.robobinding.android-aspectj'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.voicesense.hr_dialer"
minSdkVersion 15
targetSdkVersion 21
}
signingConfigs {
release {
storeFile file("../../../../../../home/amitai/personality-profiling-dialer_key.keystore")
storePassword System.getenv("KSTOREPWD")
keyAlias "alias_name"
keyPassword System.getenv("KEYPWD")
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
retrolambda {
jvmArgs '-noverify'
}
ext {
//robobindingVersion = 'latest.integration'
robobindingVersion = '0.8.9'
}
dependencies {
compile files('libs/acra-4.5.0.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:support-v13:20.0.0'
//compile 'com.netflix.rxjava:rxjava-android:0.20.7'
compile 'io.reactivex:rxandroid:0.24.0'
//compile 'com.googlecode.libphonenumber:geocoder:2.16'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0'
compile ("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
aspectPath ("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
apt "org.robobinding:codegen:$robobindingVersion"
}
And here is a zipped Android Studio project that can be used to reproduce (contains a relevant build.gradle file and a lambda expression that fails to compile).
After some investigation I found out it had to do with AspectJ not being compatible with Java 8.
I believe Java 8 Compatiblity/Update AspectJ · Issue #22 · JakeWharton/hugo and Java 8 not supported · Issue #6 · uPhyca/gradle-android-aspectj-plugin have the same issue. Any suggestions?
I made my own plugin supports aspectj with retrolambda.
GradleAndroidAspectJPlugin
When the project is using retrolambda. You have to recompile the classes using ant iajc after retrolamda compiled.
project.configurations {
aspectjTaskClasspath
aspectsInPath
}
project.repositories {
mavenCentral()
}
def aspectjVersion = '1.8.5';
project.dependencies {
//AspectJ
aspectjTaskClasspath "org.aspectj:aspectjtools:$aspectjVersion"
compile "org.aspectj:aspectjrt:$aspectjVersion"
}
project.afterEvaluate {
project.android.applicationVariants.all { variant ->
def buildTypeName = variant.name.capitalize()
def hasRetrolambda = project.plugins.hasPlugin('me.tatarka.retrolambda')
def copyDir = new File("${project.buildDir.absolutePath}/copyClasses")
if (copyDir.exists()) {
copyDir.deleteDir()
}
copyDir.mkdirs()
def copyClassTask = project.task("copy${buildTypeName}Classes", type: Copy) {
from variant.javaCompile.destinationDir
into copyDir
doLast {
variant.javaCompile.destinationDir.deleteDir()
variant.javaCompile.destinationDir.mkdirs()
}
}
def aspectsInPaths = [];
def aspectsInPathsAbsolute = [];
def aopTask = project.task("compile${buildTypeName}AspectJ") {
doFirst {
project.configurations.aspectsInPath.each {
aspectsInPaths.add(it);
aspectsInPathsAbsolute.add(it.absolutePath);
}
}
doLast {
ant.taskdef(
resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
classpath: project.configurations.aspectjTaskClasspath.asPath
)
ant.iajc(
source: project.android.compileOptions.sourceCompatibility,
target: project.android.compileOptions.targetCompatibility,
fork: "true",
destDir: variant.javaCompile.destinationDir,
bootClasspath: project.android.bootClasspath.join(File.pathSeparator),
inpathDirCopyFilter: "java/**/*.class"
) {
classpath {
variant.javaCompile.classpath.each {
if (!aspectsInPathsAbsolute.contains(it)) {
pathElement(location: it)
}
}
}
inpath {
pathElement(location: copyDir)
aspectsInPaths.each {
if (!it.name.startsWith("aspectjrt")) {
pathElement(location: it)
}
}
}
}
}
}
aopTask.dependsOn(copyClassTask);
def filterPreDexTask = project.task("filter${buildTypeName}PreDex") {
doLast {
def finalPreDexJars = []
project.tasks["preDex${buildTypeName}"].inputFiles.each {
if (it.name.startsWith("aspectjrt") ||
!aspectsInPathsAbsolute.contains(it.absolutePath)) {
finalPreDexJars.add(it)
}
}
project.tasks["preDex${buildTypeName}"].inputFiles = finalPreDexJars
}
}
project.tasks["preDex${buildTypeName}"].dependsOn(filterPreDexTask)
if (hasRetrolambda) {
project.tasks["compileRetrolambda$buildTypeName"].finalizedBy(aopTask)
} else {
project.tasks["compile${buildTypeName}Java"].finalizedBy(aopTask)
}
}
}
Related
After upgrading the Gradle plugin version to 3.0.0 (classpath "com.android.tools.build:gradle:3.0.0") and if I then try to clean or build the project I get this error:
A problem occurred configuring project ':app'.
> Manifest Tasks does not support the manifestOutputFile property any
more, please use the manifestOutputDirectory instead.
For more information, please check
https://developer.android.com/studio/build/gradle-plugin-3-0-0-
migration.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
* Get more help at https://help.gradle.org
I am not using manifestOutputFile anywhere in any of my gradle files. using the --debug and --stacktrace flags did nothing for me. I'm guessing this issue is coming up in one of my dependencies but I have no idea. Also, I am using Kotlin in a lot of classes; I'm not sure if that matters or not. Does anyone know if there is a way to see which library is throwing this error? Or does anyone have any suggestions or insight around this issue when the build.gradle file does not even reference manifestOutputFile?
Here's most of the build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://maven.google.com'}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.4'
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath 'gradle.plugin.com.nobleworks_software.icon-overlay:icon-overlay-plugin:1.2.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'jacoco-android'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.nobleworks_software.icon-overlay'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
ext {
libsSrcDir = new File('${projectDir}/libs')
}
String gpsPropertyName = 'gps'
String gpsPropertyValueAlpha = 'alpha'
String gpsPropertyValueBeta = 'beta'
boolean tangoBuild = false
String tangoPropertyName = 'tango'
String alphaBuildEnding = '20'
String betaBuildEnding = '10'
String productionBuildEnding = '00'
def isBuildForGPS = { ->
return project.hasProperty(gpsPropertyName)
}
def isTangoBuild = { ->
return project.hasProperty(tangoPropertyName)
}
def getBranchName = { ->
try {
def branchOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'symbolic-ref', '--short', 'HEAD'
standardOutput = branchOut
}
return branchOut.toString().trim()
}
catch (ignored) {
return 'master'
}
}
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'HEAD'
standardOutput = stdout
}
// Make the Tango version use '50' as the least sig offset
int tangoOffset = 0
if (tangoBuild) {
tangoOffset = 50
}
if (isBuildForGPS()) {
String channel = project.findProperty(gpsPropertyName)
if (gpsPropertyValueAlpha == channel) {
return Integer.parseInt(stdout.toString().trim() + alphaBuildEnding) + tangoOffset
} else if (gpsPropertyValueBeta == channel) {
return Integer.parseInt(stdout.toString().trim() + betaBuildEnding) + tangoOffset
}
}
return Integer.parseInt(stdout.toString().trim() + productionBuildEnding) + tangoOffset
}
catch (ignored) {
return -1
}
}
def getVersionName = { ->
try {
if (isBuildForGPS()) {
def tag = getLastTaggedVersion()
String channel = project.findProperty(gpsPropertyName)
if (gpsPropertyValueAlpha == channel) {
tag = tag + '-a'
} else if (gpsPropertyValueBeta == channel) {
tag = tag + '-b'
}
return tag
} else {
return getBranchName()
}
}
catch (ignored) {
return 'X.X.X'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
dataBinding {
enabled = true
}
defaultConfig {
versionCode getVersionCode()
versionName getVersionName()
applicationId getApplicationId()
minSdkVersion 16
targetSdkVersion 26
multiDexEnabled = true
multiDexKeepFile file('multidex_keep_file.txt')
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "com.demoapp.demoapp.WayTestRunner"
renderscriptTargetApi 16
renderscriptSupportModeEnabled true
String branchName = getBranchName().toUpperCase()
String iconOverlayText = branchName.toLowerCase()
buildConfigField "String", "LAST_TAGGED_VERSION", "\"${getLastTaggedVersion()}\""
if (branchName == 'DEV') {
iconOverlayText = 'ALPHA'
} else if (branchName.startsWith('RELEASE')) {
iconOverlayText = 'BETA'
}
if (!isBuildForGPS()) {
iconOverlay {
enabled = true
fontSize = 8
textColor = [255, 255, 255, 255]
verticalLinePadding = 2
backgroundOverlayColor = [0, 0, 0, 180]
text = { "$iconOverlayText" }
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
flavorDimensions("store", "3d_enabled")
productFlavors {
demoapp {
dimension = "store"
applicationId getApplicationId()
// Dupe required because SearchRecentSuggestionsProvider has no available context in its constructor
buildConfigField "String", "SEARCH_RECENT_AUTHORITY", "\"${applicationId}.WFSearchRecentSuggestionsProvider\""
// And one for the manifest
resValue "string", "SEARCH_RECENT_AUTHORITY", "${applicationId}.WFSearchRecentSuggestionsProvider"
// These need to be defined as string resources so they can be registered in the manifest.
// However in order to access them in tests it's convenient to have them also defined in BuildConfig
String deepLinkScheme = "demoappapp"
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME1", deepLinkScheme
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME2", deepLinkScheme
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME1", "\"${deepLinkScheme}\""
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME2", "\"${deepLinkScheme}\""
if (getBranchName().toUpperCase() == 'MASTER') {
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher",
appRoundIcon: "#mipmap/ic_launcher_round"
]
} else {
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher_dev",
appRoundIcon: "#mipmap/ic_launcher_dev_round"
]
}
}
demoappflavor {
dimension = "store"
applicationId getDemoappflavorApplicationId()
// Dupe required because SearchRecentSuggestionsProvider has no available context in its constructor
buildConfigField "String", "SEARCH_RECENT_AUTHORITY", "\"${applicationId}.WFSearchRecentSuggestionsProvider\""
// And one for the manifest
resValue "string", "SEARCH_RECENT_AUTHORITY", "${applicationId}.WFSearchRecentSuggestionsProvider"
// These need to be defined as string resources so they can be registered in the manifest.
// However in order to access them in tests it's convenient to have them also defined in BuildConfig
String deepLinkScheme1 = "theapp"
String deepLinkScheme2 = "demoappflavorapp"
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME1", deepLinkScheme1
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME2", deepLinkScheme2
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME1", "\"${deepLinkScheme1}\""
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME2", "\"${deepLinkScheme2}\""
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher",
appRoundIcon: "#mipmap/ic_launcher_round"
]
}
}
android.variantFilter { variant ->
def store = variant.getFlavors().get(0).name
def tango_enabled = variant.getFlavors().get(1).name
// Disable building the tango dimension
if ((store == 'demoappflavor' || !isTangoBuild()) && tango_enabled == "tangoEnabled") {
variant.setIgnore(true)
}
}
buildTypes {
release {
// Commented out to stop a production build crash with OKIO
//minifyEnabled true
// Commented out due to Gradle 2.2.0 issue
//shrinkResources true
ext.enableCrashlytics = true
apply plugin: 'signing'
signingConfig signingConfigs.release
ext.betaDistributionReleaseNotesFilePath = './release-notes.txt'
ext.betaDistributionGroupAliases = 'android-nightly'
buildConfigField 'boolean', 'OVERRIDE_MIN_VERSION', isBuildForGPS() ? 'false' : 'true'
buildConfigField 'boolean', 'ENABLE_APPSEE', isBuildForGPS() ? 'true' : 'false'
}
debug {
// TODO: Uncomment this out to enable code coverage
// testCoverageEnabled true
buildConfigField 'boolean', 'OVERRIDE_MIN_VERSION', isBuildForGPS() ? 'false' : 'true'
buildConfigField 'boolean', 'ENABLE_APPSEE', isBuildForGPS() ? 'true' : 'false'
}
configurations.all {
resolutionStrategy {
force 'com.google.code.findbugs:jsr305:1.3.9'
force 'com.google.guava:guava:21.0'
force "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
force 'com.google.code.gson:gson:2.8.2'
}
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'bin/AndroidManifest.xml'
exclude 'bin/jarlist.cache'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
return 0
}
testOptions {
// Disable animations for UI testing
animationsDisabled = true
unitTests.returnDefaultValues = true
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
configurations {
demoappTangoEnabledCompile
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://clojars.org/repo/" }
}
}
ext.daggerVersion = '2.11'
ext.playServicesVersion = '11.6.2'
ext.supportLibsVersion = '27.0.1'
ext.robolectricVersion = '3.3.2'
ext.frescoVersion = '1.5.0'
ext.leakCanaryVersion = '1.5.4'
ext.roomVersion ='1.0.0'
ext.butterKnifeVersion ='8.7.0'
ext.espressoVersion ='3.0.1'
ext.gsonVersion ='2.8.2'
ext.mockitoVersion ='2.9.0'
ext.dexmakerVersion ='1.2'
ext.icepickVersion ='3.2.0'
ext.multidexVersion ='1.0.2'
dependencies {
// Compile Project
compile(project(':models'))
// Compile
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
// GOOGLE LIBS
compile "com.android.support:design:${supportLibsVersion}"
compile "com.android.support:recyclerview-v7:${supportLibsVersion}"
compile "com.android.support:cardview-v7:${supportLibsVersion}"
compile "com.android.support:support-v4:${supportLibsVersion}"
compile "com.android.support:support-v13:${supportLibsVersion}"
compile "com.android.support:percent:${supportLibsVersion}"
compile "com.android.support:support-annotations:${supportLibsVersion}"
compile "com.android.support:appcompat-v7:${supportLibsVersion}"
compile "com.android.support:multidex:${multidexVersion}"
compile "com.google.code.gson:gson:${gsonVersion}"
// FIREBASE AND PLAY SERVICES
compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
compile "com.google.firebase:firebase-appindexing:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-analytics:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-auth:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-wallet:${playServicesVersion}"
// FLOW LAYOUT FOR CHIPS
compile 'org.apmem.tools:layouts:1.10#aar'
// RxJava and related
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile project(':FloatingSearchView')
// RxJava support for Room
compile 'android.arch.persistence.room:rxjava2:1.0.0'
// Testing support
androidTestCompile 'android.arch.core:core-testing:1.1.0'
// Dagger
compile "com.google.dagger:dagger:${daggerVersion}"
compile "com.google.dagger:dagger-android-support:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
kapt "com.google.dagger:dagger-android-processor:${daggerVersion}"
compile ("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile "com.jakewharton:butterknife:${butterKnifeVersion}"
kapt "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.appsee:appsee-android:2.3.4'
compile 'commons-io:commons-io:2.5'
compile "com.android.support.test:runner:1.0.1"
// ESPRESSO
androidTestCompile "com.android.support:support-v4:${supportLibsVersion}"
androidTestCompile "com.android.support:support-annotations:${supportLibsVersion}"
androidTestCompile "com.android.support:recyclerview-v7:${supportLibsVersion}"
androidTestCompile "com.android.support:design:${supportLibsVersion}"
androidTestCompile "com.android.support:recyclerview-v7:${supportLibsVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-intents:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-web:${espressoVersion}"
androidTestCompile "org.mockito:mockito-core:${mockitoVersion}"
androidTestCompile "com.google.dexmaker:dexmaker:${dexmakerVersion}"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
androidTestCompile "com.android.support:multidex:${multidexVersion}"
androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
androidTestCompile "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
androidTestCompile "com.google.code.gson:gson:${gsonVersion}"
androidTestCompile('com.jakewharton.espresso:okhttp3-idling-resource:1.0.0') {
//Using App Version Instead
exclude group: 'com.squareup.okio', module: 'okio'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
//WireMock
androidTestCompile( project(":wiremock")) {
//Using Android Version Instead
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.ow2.asm', module: 'asm'
//Using Android Version Instead
exclude group: 'org.json', module: 'json'
exclude group: 'com.google.guava', module: 'guava'
}
androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:${mockitoVersion}"
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile "org.robolectric:robolectric:${robolectricVersion}"
testCompile "org.robolectric:shadows-multidex:${robolectricVersion}"
testCompile "org.robolectric:shadows-support-v4:${robolectricVersion}"
testCompile "com.google.code.gson:gson:${gsonVersion}"
testCompile "com.google.dagger:dagger:${daggerVersion}"
testCompile "com.android.support:multidex:${multidexVersion}"
kaptTest "com.google.dagger:dagger-compiler:${daggerVersion}"
// Kotlin mockito
testCompile ("com.nhaarman:mockito-kotlin-kt1.1:1.5.0"){
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
}
compile "frankiesardo:icepick:${icepickVersion}"
provided "frankiesardo:icepick-processor:${icepickVersion}"
compile "com.facebook.fresco:fresco:${frescoVersion}"
compile "com.facebook.fresco:animated-gif:${frescoVersion}"
// Canary
debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
androidTestCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
compile 'com.prolificinteractive:material-calendarview:1.4.3'
//Card IO
compile 'io.card:android-sdk:5.5.1'
compile 'com.facebook.rebound:rebound:0.3.8'
//Chrome Web-View
compile "com.android.support:customtabs:${supportLibsVersion}"
def folder = new File('./brickkit-android/BrickKit/bricks/build.gradle')
if (folder.exists()) {
compile project(':bricks')
} else {
compile 'com.demoapp:brickkit-android:0.9.27'
}
// intellij annotations are included in kotlin, so this creates
// a "java.util.zip.ZipException: duplicate entry" on its modules
//compile 'com.intellij:annotations:12.0#jar'
testCompile "com.google.dagger:dagger:${daggerVersion}"
demoappTangoEnabledCompile project(':demoappView')
compile ('com.perimeterx.sdk:msdk:1.1.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
// Kotlin support
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
//Data binding
kapt "com.android.databinding:compiler:$gradleVersion"
compile 'nl.littlerobots.rxlint:rxlint:1.4'
// Room
compile "android.arch.persistence.room:runtime:${roomVersion}"
kapt "android.arch.persistence.room:compiler:${roomVersion}"
androidTestCompile "android.arch.persistence.room:testing:${roomVersion}"
// Stetho
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.facebook.stetho:stetho-js-rhino:1.4.2'
compile 'com.siftscience:sift-android:0.9.10'
}
import groovy.json.JsonBuilder
task uploadapithingFiles << {
// Get all the apithing files
String apithingDir = "${project.rootDir}/models/src/main/java/com/demoapp/models/requests/apithing-files"
FileTree files = fileTree(dir: apithingDir)
// TreeMap of File names and File Data
TreeMap<String, String> fileMap = new TreeMap<>()
files.each { file ->
Scanner input = new Scanner(file)
String output = ""
while (input.hasNext()) {
output = output + input.nextLine()
}
input.close()
fileMap.put(file.name.take(file.name.lastIndexOf('.')), output)
}
// Build request JSON
def json = new JsonBuilder()
json{
payload {
build_id getVersionCode()
client_id 2
version lastTaggedVersion
is_production isBuildForGPS() ? 1 : 0
queries fileMap.collect {
[
"name": it.key,
"query": it.value
]
}
}
}
// Create POST Request
def url = 'http://services.demoapp.com:8280/purest/performance/app_apithing'
def post = new URL(url).openConnection()
def message = json.toString()
projects.logger.debug(message)
post.setRequestMethod("POST")
post.setRequestProperty("Content-Type", "application/json; charset=utf-8")
post.setDoOutput(true)
post.getOutputStream().write(message.getBytes("UTF-8"))
def responseCode = post.getResponseCode()
if(responseCode >= 200 && responseCode <= 299) {
projects.logger.lifecycle("apithing upload successful.")
} else {
projects.logger.lifecycle("apithing Upload Failed with response: ${post.getResponseMessage()}")
throw new GradleException("ERROR: Unable to upload apithing files. Server returned a response code: ${responseCode}")
}
}
project.gradle.taskGraph.whenReady {
->
project.tasks.findAll { it.name =~ /connected.+AndroidTest/ }.each {
it.ignoreFailures = true
}
}
def errorOutput(dir) {
println "\n\n================OUTPUT REPORT=================\n\n"
println "The file $dir does not exist\n "
println "Check the current APK Path and Version "
println "\n\n==============================================\n\n"
}
def executeUpload(dir, isUpload, key) {
if (isUpload) {
exec {
commandLine 'curl', 'https://tok_gh6e7yrydkhgqyaz2fvx702y8m#api.appetize.io/v1/apps', '-F', "file=#$dir", '-F', 'platform=android'
}
} else {
exec {
commandLine 'curl', "https://tok_gh6e7yrydkhgqyaz2fvx702y8m#api.appetize.io/v1/apps/$key", '-F', "file=#$dir", '-F', 'platform=android'
}
}
}
apply plugin: 'com.google.gms.google-services'
jacocoAndroidUnitTestReport {
excludes += ['**/R.class','**/R$*.class','**/*$ViewInjector*.*','**/*$ViewBinder*.*','**/BuildConfig.*','**/Manifest*.*','**/*$Lambda$*.*','**/*Module.*','**/*Dagger*.*','**/*MembersInjector*.*','**/*_Provide*Factory*.*','**/*_Factory*.*','**/*$*$*.*','**/test*/**','**/androidTest/**','**/databinding/**']
}
tasks.whenTaskAdded { task ->
if (task.name == 'connecteddemoappDebugAndroidTest' || task.name == 'connecteddemoappflavorDebugAndroidTest') {
task.doFirst() {
exec {
commandLine 'sh', 'get_android_wiremock.sh'
}
}
task.doLast() {
exec {
commandLine 'sh', 'get_device_recordings.sh', 'wiremock_blacklist.txt'
}
}
}
}
android.applicationVariants.all { variant ->
task("checkstyle${variant.name.capitalize()}", type: Checkstyle) {
configFile file("${project.rootDir}/config/quality/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/models/generated/**'
classpath = files() as FileCollection
group = "verification"
}
check.dependsOn("checkstyle${variant.name.capitalize()}")
}
android.applicationVariants.all { variant ->
task("findbugs${variant.name.capitalize()}", type: FindBugs) {
ignoreFailures = false
effort = "default"
reportLevel = "medium"
excludeFilter = new File("${project.rootDir}/config/quality/findbugs/findbugs-filter.xml")
classes = files("${project.rootDir}/app/build/intermediates/classes")
source = fileTree('src/main/java/')
classpath = files()
group = "verification"
reports {
xml.enabled = false
html.enabled = true
xml {
destination "$project.buildDir/findbugs/findbugs-output.xml"
}
html {
destination "$project.buildDir/findbugs/findbugs-output.html"
}
}
dependsOn "compile${variant.name.capitalize()}JavaWithJavac"
}
check.dependsOn("findbugs${variant.name.capitalize()}")
}
android.applicationVariants.all { variant ->
task("buildCheckTest${variant.name.capitalize()}", type: GradleBuild) {
dependsOn "checkstyle${variant.name.capitalize()}"
dependsOn "assemble${variant.name.capitalize()}"
dependsOn "lint${variant.name.capitalize()}"
dependsOn "findbugs${variant.name.capitalize()}"
dependsOn "test${variant.name.capitalize()}UnitTest"
dependsOn "jacocoTest${variant.name.capitalize()}UnitTestReport"
mustRunAfter "clean"
}
}
task buildReleaseTest(type: GradleBuild)
android.applicationVariants.all { variant ->
if (variant.name.endsWith("Release")) {
buildReleaseTest.dependsOn("buildCheckTest${variant.name.capitalize()}")
}
}
android.applicationVariants.all { v ->
if (v.buildType.name == "release"){
v.assemble.dependsOn("uploadapithingFiles")
}
}
buildReleaseTest.mustRunAfter('clean')
task cleanBuildReleaseTest(type: GradleBuild)
cleanBuildReleaseTest.dependsOn('clean')
cleanBuildReleaseTest.dependsOn('buildReleaseTest')
Whoa, that's a lot of plugins. The error message comes because one of them depends on an API that was changed in 3.x (hence migration link). You'll need to update the corresponding plugin.
Based on gradle dependencies run at step 3 below, my guess is gradle.plugin.com.nobleworks_software.icon-overlay:icon-overlay-plugin. It shows com.android.tools.build:gradle:2.2.3 -> 3.0.1 nested under.
(gradlew buildEnvironment on your project may also give you a similar result if you add 3.0.1 Android Gradle Plugin to your build.gradle)
--stacktrace should have also given you the exact location where com.android.build.gradle.tasks.ManifestProcessorTask#getManifestOutputFile was called from. If it doesn't you can still do below:
This is a way I would answer this question if I had an mvce. You have too many plugins to set up everything manually from scratch. This method is also applicable to any Gradle buildscript weirdness in plugins.
Close your project in AS/IDEA
Note: if you have a buildSrc in your project that could also work, so there's no need to close and create another.
Create another project (let's call it debugger) with build.gradle file as follows:
buildscript {}'s contents from your project (but no buildscript block!)
repositories {
jcenter()
...
}
dependencies {
implementation ... // for each classpath ...
}
add plugins { id 'java' } on root level
add implementation 'com.android.tools.build:gradle:3.0.1' inside dependencies
Open this project in IDEA/Android Studio
(this will download all the sources for those plugins)
Run gradlew --no-daemon -Dorg.gradle.debug=true --debug --stacktrace from terminal
(this will stop executing and wait,
note: Listening for transport dt_socket at address: 5005)
Go to "Run/Debug configurations" dialog in debugger project
Create a "Remote" configuration (green +) with parameters from Gradle's log:
Close dialog with OK / Apply
Jump to class/file com.android.build.gradle.tasks.ManifestProcessorTask inside gradle-core-3.0.1-sources.jar
Put a breakpoint at line 128 in ManifestProcessorTask.getManifestOutputFile
To be safe repeat above two steps for gradle-core-3.0.1.jar's decompiled code as well. (line number may differ)
Run menu > Debug "Remote"
Wait and celebrate when breakpoint hits and you see who calls the method in the Debug view's Stack frame listing.
It looks overwhelming, but it's quite simple and fast after you did this once.
Today downloaded the studio 3.0 beta 2.0 version, after that tried to open an existing project in it and faced some difficulties, most of them I could solve with the help of Google and Stack Overflow, but this one I can not.
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Also posting my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.intersoft.snappy"
minSdkVersion 19
targetSdkVersion 22
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypeMatching 'dev', 'debug'
buildTypeMatching 'qa', 'debug'
buildTypeMatching 'rc', 'release'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/']
} }
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url "https://jitpack.io" }
maven { url 'https://dl.bintray.com/ashokslsk/CheckableView' }
maven { url "https://maven.google.com" }
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.github.mrengineer13:snackbar:1.2.0'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.android.support:cardview-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support:percent:26.0.1'
implementation 'dev.dworks.libs:volleyplus:+'
implementation 'com.google.guava:guava:21.0'
implementation 'com.facebook.fresco:fresco:1.0.1'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.wdullaer:materialdatetimepicker:3.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.stfalcon:frescoimageviewer:0.4.0'
implementation 'com.github.piotrek1543:CustomSpinner:0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.github.satyan:sugar:1.4'
implementation 'com.hedgehog.ratingbar:app:1.1.2'
implementation project(':sandriosCamera')
implementation('org.apache.httpcomponents:httpmime:4.2.6') {
exclude module: 'httpclient'
}
implementation 'com.googlecode.json-simple:json-simple:1.1'
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
} else if
("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
}
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
apply plugin: 'com.jakewharton.hugo'
also my another module gradle
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
buildscript {
repositories {
jcenter()
jcenter()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
group = 'com.sandrios.android'
version = '1.0.8'
ext {
PUBLISH_GROUP_ID = 'com.sandrios.android'
PUBLISH_ARTIFACT_ID = 'sandriosCamera'
PUBLISH_VERSION = '1.0.8'
PUBLISH_CODE = 9
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode PUBLISH_CODE
versionName PUBLISH_VERSION
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task generateJavadocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator))
}
task generateJavadocsJar(type: Jar) {
from generateJavadocs.destinationDir
classifier 'javadoc'
}
generateJavadocsJar.dependsOn generateJavadocs
artifacts {
archives generateSourcesJar
archives generateJavadocsJar
}
install {
repositories.mavenInstaller {
pom.project {
name PUBLISH_GROUP_ID
description 'Simple integration of universal camera in android for easy image and video capture.'
url 'https://github.com/sandrios/sandriosCamera'
inceptionYear '2016'
packaging 'aar'
version PUBLISH_VERSION
scm {
connection 'https://github.com/sandrios/sandriosCamera.git'
url 'https://github.com/sandrios/sandriosCamera'
}
developers {
developer {
name 'arpitgandhi9'
}
}
}
}
}
bintray {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty('bintray.user')
key = properties.getProperty('bintray.apikey')
configurations = ['archives']
pkg {
repo = 'android'
name = 'sandriosCamera'
userOrg = 'sandriosstudios'
desc = 'Android solution to simplify work with different camera apis.'
licenses = ['MIT']
labels = ['android', 'camera', 'photo', 'video']
websiteUrl = 'https://github.com/sandrios/sandriosCamera'
issueTrackerUrl = 'https://github.com/sandrios/sandriosCamera/issues'
vcsUrl = 'https://github.com/sandrios/sandriosCamera.git'
version {
name = PUBLISH_VERSION
vcsTag = PUBLISH_VERSION
desc = 'Minor fixes.'
released = new Date()
}
}
}
repositories {
jcenter()
}
dependencies {
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'gun0912.ted:tedpermission:1.0.2'
}
and also project level gradle
// 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:3.0.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
please help me to get rid of this error
It is important part:
You need to add this in that module's build.gradle where it's not added like app module.
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Also you forgot to add repo for plugin:
buildscript {
repositories {
jcenter()
google()
}
}
I had the same errors(SimException) that you encountered. I had 3 modules in android clean architecture project:
data(android library)
domain(plain java module)
presentation(app - all android stuff)
solution
navigate to File/Project Structure...
make sure your modules has the same Source and Target Compatibility (1.8 in this case)
I added a library with the compileOptions Java 1.8, and In my main project dont.
Fixed adding:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Found my answer, for me personally it was using
implementation "com.google.guava:guava:23.0"
Instead of
implementation "com.google.guava:guava:23.0-android"
I was having the same issue. I had recently deleted my .gradle cache folder, and reinstalled Android Studio and the SDK. Eventually when trying to git bisect the problem, it went away. I can only speculate as to why this happened, but I suspect that downloading older versions of the build tools and SDK, and building (and presumably caching) versions of our code with those older tools caused it to be built in a way that didn't cause issues.
This points to some sort of bug in the way that the newer (API 26?) build tools are building the source code, and so my recommendation if you're seeing this problem and the other solutions don't work, is to lower your target SDK version to 25 or lower, install the necessary build tools, and try compiling your code with those, before reverting to build tools 26 or higher.
I have imported a code from github in my git repo and from there I have imported the project in Android Studio but after the gradle build at the time of gradle sync it is giving this error :-
Error:(12, 0) CreateProcess error=2, The system cannot find the file specified Open File
Can anyone help please fast .
this is my build.gradle file
if ((new File(gradle.local)).exists()) {
apply from: gradle.local
} else {
apply from: gradle.remote
}
applicationScripts.each {
apply from: it
}
apply plugin: 'com.android.application'
com.android.ddmlib.DdmPreferences.setTimeOut(60000)
android {
// The following are set in the common.gradle file
compileSdkVersion(compileVersion)
buildToolsVersion(buildTools)
defaultConfig {
applicationId("org.odk.collect.android")
minSdkVersion(9)
targetSdkVersion(9)
versionCode(1061)
versionName("1.4.10")
}
productFlavors {
demo {
}
master {
}
snapshot {
}
uitest {
}
}
signingConfigs {
release {
if (shouldSign) {
storeFile file(signStoreFilePath)
storePassword signStorePass
keyAlias signKeyAlias
keyPassword signKeyPass
}
}
}
buildTypes {
release {
minifyEnabled(minify)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
if (shouldSign) {
signingConfig signingConfigs.release
}
}
debug {
debuggable(true)
testCoverageEnabled(testCoverage) // Allows AndroidTest JaCoCo reports to be generated
}
}
packagingOptions { // Pick first occurrence of any files that cause conflicts, as defined in common.gradle
packageList.each {
pickFirst it
}
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
}
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor(0, 'seconds')
cacheChangingModulesFor(0, 'seconds')
}
transitive = true
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.android.gms:play-services:4.1.32'
// Testing-only dependencies
testCompile 'junit:junit:4.12'
}
I am attempting to follow the Android Studio Experimental Plugin User Guide instructions located at:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental
to modify the Mapbox GL Native library located at:
https://github.com/mapbox/mapbox-gl-native
In specific, I have modified the following Android files:
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/gradle/wrapper/gradle-wrapper.properties
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/build.gradle
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/build.gradle
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
My goal is to modify the library so I can debug it. Ideally I would be able to use Android Studio to build the library and debug the C/C++ code. So far I can build it, but I can't debug it. A programmer working at Mapbox told me they don't how to debug the Android code either, so I suspect this isn't an easy goal to reach.
I have made many different attempts to apply the Android Studio Experimental Plugin User Guide instructions, but I'm not experienced at Gradle and my latest attempt is leaving me with the following error message which I don't understand:
Gradle 'android' project refresh failed
Error:Cause:org.gradle.api.internal.ExtensibleDynamicObject
Does anyone know how to modify these files to have them build a debuggable Android NDK Library? What is causing the above error?
I am using:
> Linux Mint 17.2
> Android Studio 2.1.1
> Build #AI-143.2821654, built on April 28, 2016
> JRE: 1.8.0_65-b17 amd64
> JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Below are the 4 files as I currently have them modified. Since I am new to Gradle, do not assume I have made any modfications correctly. I was merely attempting to apply the Android Studio Experimental Plugin User Guide instructions until I got a successful build.
Thanks
#// mapbox-gl-native/platform/android/gradle/wrapper/gradle-wrapper.properties
#Thu Apr 07 14:21:05 CDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#//distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
#//distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
distributionSha256Sum=e77064981906cd0476ff1e0de3e6fef747bd18e140960f1915cca8ff6c33ab5c
// mapbox-gl-native/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.1.0'
//classpath 'com.android.tools.build:gradle-experimental:0.7.0'
classpath 'com.android.tools.build:gradle-experimental:0.8.0-alpha2'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
// mapbox-gl-native/platform/android/MapboxGLAndroidSDK/build.gradle
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.model.library'
apply plugin: 'checkstyle'
apply plugin: 'maven'
apply plugin: 'signing'
allprojects {
group project.GROUP
version project.VERSION_NAME
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
ext {
supportLibVersion = '23.4.0'
}
dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.mapzen.android:lost:1.1.0'
}
model {
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
sourceSets {
main.res.srcDirs += 'src/main/res-public'
}
repositories {
mavenCentral()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
}
buildTypes {
debug {
jniDebuggable true
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT_BASE", new StringBuilder().append("\"").append("MapboxEventsAndroid/").append(project.VERSION_NAME).append("\"").toString()
}
release {
jniDebuggable false
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT_BASE", new StringBuilder().append("\"").append("MapboxEventsAndroid/").append(project.VERSION_NAME).append("\"").toString()
consumerProguardFiles 'proguard-rules.pro'
}
}
}
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'commons-collections', module: 'commons-collections'
}
model {
android.libraryVariants.all { variant ->
def name = variant.name
task "javadoc$name"(type: Javadoc) {
description = "Generates javadoc for build $name"
failOnError = false
destinationDir = new File(destinationDir, variant.baseName)
source = files(variant.javaCompile.source)
classpath = files(variant.javaCompile.classpath.files) + files(android.bootClasspath)
exclude '**/R.java', '**/BuildConfig.java', 'com/almeros/**'
options.windowTitle("Mapbox Android SDK $VERSION_NAME Reference")
options.docTitle("Mapbox Android SDK $VERSION_NAME")
options.header("Mapbox Android SDK $VERSION_NAME Reference")
options.bottom("© 2015–2016 Mapbox. All rights reserved.")
options.links("http://docs.oracle.com/javase/7/docs/api/")
options.linksOffline("http://d.android.com/reference/", "$System.env.ANDROID_HOME/docs/reference")
options.overview("src/main/java/overview.html")
options.group("Mapbox Android SDK", "com.mapbox.*")
options.group("Third Party Libraries", "com.almeros.*")
// TODO exclude generated R, BuildConfig, com.almeros.*
}
}
}
checkstyle {
configFile project.file('../checks.xml')
showViolations true
}
/*
task cleanJNIBuilds {
def jniLibsDir = new File("MapboxGLAndroidSDK/src/main/jniLibs")
delete jniLibsDir.absolutePath
}
*/
model
{
android.libraryVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
checkstyle.exclude('**/com/almeros/android/multitouch/**')
project.tasks.getByName("check").dependsOn checkstyle
}
// From https://raw.github.com/mcxiaoke/gradle-mvn-push/master/jar.gradle
android.libraryVariants.all { variant ->
def jarTask = project.tasks.create(name: "jar${variant.name.capitalize()}", type: Jar) {
from variant.javaCompile.destinationDir
exclude "**/R.class"
exclude "**/BuildConfig.class"
}
jarTask.dependsOn variant.javaCompile
artifacts.add('archives', jarTask);
}
}
// From https://raw.github.com/mcxiaoke/gradle-mvn-push/master/gradle-mvn-push.gradle
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL :
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL :
"https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('USERNAME') ? USERNAME :
(hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "")
}
def getRepositoryPassword() {
return hasProperty('PASSWORD') ? PASSWORD :
(hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "")
}
task apklib(type: Zip) {
appendix = extension = 'apklib'
from 'AndroidManifest.xml'
into('res') {
from 'res'
}
into('src') {
from 'src'
}
}
artifacts {
archives apklib
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(),
password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(),
password: getRepositoryPassword())
}
/*
// Leaving out as artifact was incorrectly named when found
addFilter('aar') { artifact, file ->
artifact.name == archivesBaseName
}
addFilter('apklib') { artifact, file ->
artifact.name == archivesBaseName + '-apklib'
}
*/
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
model {
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.sourceFiles
classpath = files(android.bootClasspath)
}
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
model {
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
task makeClean(type: Exec) {
workingDir '../../'
commandLine 'make', 'clean'
}
task makeAndroid(type: Exec) {
workingDir '../../'
commandLine 'make', 'android'
}
task makeAndroidAll(type: Exec) {
workingDir '../../'
commandLine 'make', 'apackage'
}
// mapbox-gl-native/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.model.application'
apply plugin: 'checkstyle'
task accessToken {
def tokenFile = new File("MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml")
if (!tokenFile.exists()) {
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<resources>\n" +
" <string name=\"mapbox_access_token\">" + "$System.env.MAPBOX_ACCESS_TOKEN" + "</string>\n" +
"</resources>"
if (tokenFileContents == null) {
throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.")
}
tokenFile.write(tokenFileContents)
}
}
gradle.projectsEvaluated {
// preBuild.dependsOn('accessToken')
}
ext {
supportLibVersion = '23.4.0'
}
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mapbox.mapboxsdk.testapp"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 23
versionCode 9
versionName "4.1.0"
// Specify AndroidJUnitRunner as the default test instrumentation runner
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
disable 'IconDensities'
disable 'InvalidPackage'
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
debug {
// run code coverage reports
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
}
dependencies {
compile(project(':MapboxGLAndroidSDK')) {
transitive = true
}
// Support libraries
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
// Leak Canary
//debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
//releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
// Directions SDK
compile('com.mapbox.mapboxsdk:mapbox-android-directions:1.0.0#aar') {
transitive = true
}
// Geocoder SDK
compile('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0#aar') {
transitive = true
}
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4'
}
checkstyle {
configFile project.file('../checks.xml')
showViolations true
}
model {
android.applicationVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
project.tasks.getByName("check").dependsOn checkstyle
}
}
Your gradle approach is essentially rewriting or porting the Android SDK Makefile to gradle. To solve what you are doing on Linux, you will likely need to modify the existing Makefiles.
The reason is that the Mapbox Android SDK build process uses make android to build the target libmapbox-gl.so. The Gradle project you have includes the .so file in with your usual Java code.
make android makes a call into mapbox-gl-native/Makefile
and also generates mapbox-gl-native/build/android-arm-v7/Makefile, which you may have to research how to modify to generate debug information as Chris Stratton mentions in the comments above.
When you do get around to modifying your C++, you will then need to modify the settings.gradle to make use of your modified .so for Android.
include ':MapboxGLAndroidSDK'
project(':MapboxGLAndroidSDK').projectDir = new File(rootProject.projectDir, '<relative-path-to>/../mapbox-gl-native/platform/android/MapboxGLAndroidSDK')
include ':app'
Another thing to consider — Can you build a debuggable version for Linux?
We have successfully debugged C++ for the Mapbox SDK using the Xcode debugger, as we built an iOS app as well. I know this will not fit your exact needs, but I mention it in case anyone else in your lab or organization has access to Xcode on OS X and can start debugging using make iproj.
I have tried to import tesseract ocr project in android studio. While building gradle it showin error as following
Error:(8, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'textfairy' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
My app/build.gradle file
import java.util.regex.Pattern
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
import org.apache.tools.ant.taskdefs.condition.Os
task ndkBuild(type: Exec,description: 'run ndk-build') {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
workingDir 'src/main/jni'
commandLine 'ndk-build.cmd', '-j', Runtime.runtime.availableProcessors()
} else {
workingDir 'src/main/jni'
commandLine "$ndkDir/ndk-build", '-j', Runtime.runtime.availableProcessors()
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(ndkBuild)
}
def getVersionCodeFromManifest(String prefix) {
def manifestFile = file("src/main/AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def manifestText = manifestFile.getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def version = prefix + matcher.group(1)
println sprintf("Returning version %s", version)
return Integer.parseInt("$version")
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
testInstrumentationRunner "android.test.InstrumentationTestRunner"
//testHandleProfiling true
//testFunctionalTest true
}
signingConfigs {
release
}
buildTypes {
debug {
debuggable true
}
release {
//runProguard true
proguardFile file('android.pro')
proguardFile getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
}
productFlavors {
x86 {
versionCode getVersionCodeFromManifest("6")
ndk {
abiFilter "x86"
}
}
aV7 {
versionCode getVersionCodeFromManifest("2")
ndk {
abiFilter "armeabi-v7a"
}
}
aV5 {
versionCode getVersionCodeFromManifest("1")
ndk {
abiFilter "armeabi"
}
}
}
sourceSets {
main {
//jniLibs.srcDirs = ['native-libs']
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build
}
}
}
def Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
} else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile fileTree(dir: 'src/main/libs', include: '*.jar')
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.github.chrisbanes.photoview:library:1.2.2'
compile 'com.google.code.findbugs:jsr305:2.0.2'
compile "com.google.guava:guava:18.0"
compile 'de.greenrobot:eventbus:2.4.0'
//compile 'com.android.support:design:22.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:appcompat-v7:19.0.+'
compile 'org.apache.commons:commons-compress:1.5'
compile project(":tess-two:tess-two")
compile 'com.android.support:cardview-v7:21.0.+'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
androidTestCompile 'org.mockito:mockito-core:1.10.17'
androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-all:1.10.19"
testCompile("org.robolectric:robolectric:3.0-rc2") {
exclude group: 'commons-logging', module: 'commons-logging'
}
compile('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
}
My project root build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
}
allprojects {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
}
}
}
dependencies {
apply plugin: 'osgi'
compile project(':libraries:tess-two')
}
My settings.gradle file
include ':libraries:tess-two'
include ':app'
My gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
I have added dependencies also. Please tell me what is the problem.
Thank you
You have to change your top-level build.gradle, removing the compile line, and adding the gradle and fabric plugin.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
}
}
}
Als if you want to use the libraries:tess-two in your project, you have to add this line inside the dependecies block of your app/build.gradle file
compile project(':libraries:tess-two')
Finally move the apply plugin: 'osgi' at the beginning of the app/build.gradle file
To resolve the ndk issue you have to:
add gradle.properties file to root folder of your project
add 'android.useDeprecatedNdk=true' to gradle.properties file
Here is my gradle.properties :
android.useDeprecatedNdk=true