Cannot create variant 'android-lint' after configuration - android

I am updating my project's Gradle plugin from 2.1.2 to 3.1.0 but the gradle starts throwing error while build :
Cannot create variant 'android-lint' after configuration
':app:debugRuntimeElements' has been resolved
project level gradle :
// Top-level build file
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'org.ajoberstar:gradle-git:0.6.3'
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// Used to disable preDex, will speed up clean build but slow down incremental builds.
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
allprojects {
repositories {
jcenter()
}
}
library level gradle :
apply plugin: 'com.android.library'
setVersion '1.2'
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
configurations {
classpaths
}
def sharedManifest = manifest {
attributes('Specification-Title': 'My App',
'Specification-Version': '2.1',
'Specification-Vendor': 'App Vendor',
'Implementation-Title': 'App',
'Implementation-Version': '2.1',
'Implementation-Vendor': 'App Vendor')
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
consumerProguardFile file("proguard-project.txt")
}
buildTypes {
debug {
testCoverageEnabled true
}
}
// work-around for duplicate files during packaging of APK
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':exclude-doclet')
implementation 'com.android.support:support-annotations:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'commons-io:commons-io:2.4'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.google.code.gson:gson:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.7'
classpaths files(new File(System.getenv("ANDROID_HOME") + "/platforms/android-${Integer.parseInt(rootProject.ANDROID_BUILD_SDK_VERSION)}/android.jar"),
new File(System.getenv("ANDROID_HOME") + "/extras/android/support/v4/android-support-v4.jar"))
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
}
android.libraryVariants.all { variant ->
String name = variant.buildType.name
task("generate${name.capitalize()}Javadoc", type: Javadoc) {
dependsOn variant.javaCompiler
description "Generates Javadoc for $project.name."
title "App $project.version"
source = variant.javaCompiler.source
classpath += project.files(variant.javaCompiler.classpath.files, android.getBootClasspath())
List<File> pathList = new ArrayList<File>()
pathList.add(new File(project(':exclude-doclet').libsDir,
"ExcludeDoclet-${project(':exclude-doclet').version}.jar"))
options {
doclet = "ExcludeDoclet"
docletpath = pathList
encoding = "UTF-8"
classpath = configurations.classpaths.files.asType(List)
linksOffline "http://developer.android.com/reference", "${android.sdkDirectory}/docs/reference"
links "http://docs.oracle.com/javase/7/docs/api/",
"http://square.github.io/retrofit/2.x/retrofit/",
"http://square.github.io/okhttp/2.x/okhttp/",
"http://reactivex.io/RxJava/javadoc/"
memberLevel = JavadocMemberLevel.PUBLIC
header = "AppKit"
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError true
doLast {
copy {
from 'src/javadoc/assets/'
into destinationDir.path + '/assets/'
}
}
}
task("assemble${name.capitalize()}JavadocJar", type: Jar) {
dependsOn "generate${name.capitalize()}Javadoc"
description "Assembles Jar contaning Javadoc for $project.name."
from project.tasks.getByName("generate${name.capitalize()}Javadoc").destinationDir
classifier = 'javadoc'
manifest {
from sharedManifest
}
}
task("assemble${name.capitalize()}Jar", type: Jar) {
dependsOn variant.javaCompiler
description "Assembles Jar contaning $project.name."
from variant.javaCompiler.destinationDir
manifest {
from sharedManifest
}
}
artifacts {
archives project.tasks.getByName("assemble${name.capitalize()}Jar")
archives project.tasks.getByName("assemble${name.capitalize()}JavadocJar")
}
}
I am stuck with this issue and don't find any solution. Can anyone help me out.

I had the same issue with another library as you have.
I could resolve that with replacing this line:
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
with:
doFirst { classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) },
"This is due to new Gradle plugin when AndroidStudio gets updated that goes in conflict with JavaDoc plugin", If you have Javadoc task you must be able to find the same line.

Related

Could not resolve all files for configuration ':app:debugRuntimeClasspath gradle submodule dependency

I have a submodule project that turns into Maven repository, I'm trying to use a dependency implementation com.github.jkwiecien:EasyImage:3.0.3 other like Glide works, but this issue appears:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.jkwiecien:EasyImage:3.0.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://jcenter.bintray.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://maven.google.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://repo.maven.apache.org/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
Required by:
project :app > project : myapp
I've tried putting maven repository as:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
def githubProperties = new Properties()
githubProperties.load(
new FileInputStream(rootProject.file("github.properties"))
)
def getVersionName = { ->
return "1.0.9"
}
def getArtifactId = { ->
return "rewards"
}
publishing {
publications {
rewards(MavenPublication) {
groupId 'app.my.sdk'
artifactId getArtifactId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtifactId()}-release.aar")
pom.withXml { // adding transitive dependencies...
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
if (dep.group == null || dep.version == null ||
dep.name == null || dep.name == "unspecified")
return
final dependencyNode = dependenciesNode
.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', scope)
if (!dep.transitive) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
dep.properties.excludeRules.each { ExcludeRule rule ->
exclusionNode.appendNode(
'groupId', rule.group ?: '*')
exclusionNode.appendNode(
'artifactId', rule.module ?: '*')
}
}
} // end addDependency
configurations.compile.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.api.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.implementation.getDependencies().each { dep ->
addDependency(dep, "runtime")
}
} // end pomWithXml
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/my-project/my-lib")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
repositories {
maven {
URL "https://mvnrepository.com/artifact/com.github.jkwiecien/EasyImage"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'jp.wasabeef:blurry:4.0.0'
implementation 'io.socket:socket.io-client:1.0.0'
implementation 'com.github.jkwiecien:EasyImage:3.0.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}
This is my full gradle file. I'm working only with this module, It's suppose to be an app inside another. I'm uploading in github packages using the maven.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
To solve this issue just add jitpack on gradle project file,
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Couldn't Find com.google.android.gms:oss-licenses-plugin:0.9.3

I trying to Import my project in android studio 3.3.2 (latest version) but The IDE tell couldn't find (or download ) this plugin! I checked internet connection, firewall and other involving But can't figure it out why android studio cant download or find this plugin.
Note: I can download files by pasting link in chrome.
CONFIGURE FAILED in 8s
ERROR: Could not find com.google.android.gms:oss-licenses-plugin:0.9.4.
Searched in the following locations:
https://maven.google.com/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.pom
https://maven.google.com/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.jar
https://jcenter.bintray.com/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.pom
https://jcenter.bintray.com/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.jar
https://dl.google.com/dl/android/maven2/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.pom
https://dl.google.com/dl/android/maven2/com/google/android/gms/oss-licenses-plugin/0.9.4/oss-licenses-plugin-0.9.4.jar
Required by:
project :
So this is my gradle config ( app-level ) :
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sherdle.universal"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
//Optionally configure your OneSignal IDs below
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "",
onesignal_google_project_number: ""]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
jumboMode true
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url "https://jitpack.io"
}
jcenter()
google();
}
dependencies {
implementation 'com.devbrackets.android:exomedia:4.0.3' //TV
implementation 'com.google.android.exoplayer:exoplayer:r2.4.3' //TV & Radio
implementation 'com.cleveroad:audiovisualization:1.0.0' //Radio
implementation 'com.google.code.gson:gson:2.8.0' //WC
implementation 'com.squareup.okhttp3:okhttp:3.7.0' //WC
implementation 'org.jsoup:jsoup:1.8.3'
implementation 'com.onesignal:OneSignal:[3.9.3,4.0.0)'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.duolingo.open:rtl-viewpager:1.0.2'
implementation 'com.github.chrisbanes:PhotoView:1.3.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.android.support:cardview-v7:$supportlib_version"
implementation "com.android.support:appcompat-v7:$supportlib_version"
implementation "com.android.support:recyclerview-v7:$supportlib_version"
implementation "com.android.support:design:$supportlib_version"
implementation "com.android.support:support-v4:$supportlib_version"
implementation "com.android.support:support-core-utils:$supportlib_version"
implementation "com.android.support:support-media-compat:$supportlib_version"
implementation "com.google.android.gms:play-services-oss-licenses:$gps_version"
implementation "com.google.android.gms:play-services-gcm:$gps_version"
implementation "com.google.android.gms:play-services-ads:$gps_version"
implementation "com.google.android.gms:play-services-maps:$gps_version"
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
My project Gradle config is this ( NOT APP-LEVEL ) :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
maven {
url 'https://jitpack.io'
}
}
}
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.4'
}
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
google()
}
}
ext {
supportlib_version = '27.1.1'
gps_version = '15.0.0'
}
//Ensure that all dependencies use the same version of the Android Support library
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$supportlib_version"
}
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$gps_version"
}
if (details.requested.group == 'com.google.firebase'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$gps_version"
}
}
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
google()
}
}
}
In your root-level build.gradle make sure you are using the Google Maven repository and add the oss-licenses plugin to your dependencies:
buildscript {
repositories {
// ...
google() // maven { url "https://maven.google.com" } for Gradle <= 3
}
dependencies {
// ...
// Add this line:
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.4'
}
In your app-level build.gradle, apply the plugin by adding the following line under the existing apply plugin: 'com.android.application' at the top of the file:
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
In my case i was behind A proxy . Problem Solved by using FOD proxy Services Click for more info! in Android Studio And Everything worked fine .

invokedynamic requires --min-sdk-version >= 26

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.

Android Studio update - Failed to resolve com.android.databinding

I recently updated my JAVA to 1.8 version and also made android studio updates and gradle plugin updates as well. After the update i get following error in one of my module's(i.e. facebook module) build.gradle file on compiling my project:
My project level build.gradle looks like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-beta4'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
allprojects {
repositories {
jcenter()
}
}
Also there are few Symbol not found error like Cannot resolve Symbol 'GradleScriptException' and Cannot resolve symbol 'MavenDeployment' in facebook module build.gradle file. The full code of facebook buil.gradle is:
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
project.group = 'com.facebook.android'
dependencies {
// Facbook Dependancies
testCompile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.parse.bolts:bolts-android:1.2.1'
// Unit Tests
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:shadows-support-v4:3.0'
def powerMockVersion = '1.6.1'
testCompile "org.powermock:powermock-module-junit4:$powerMockVersion" testCompile "org.powermock:powermock-module-junit4-rule:$powerMockVersion" testCompile "org.powermock:powermock-classloading-xstream:$powerMockVersion" androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
testCompile "org.powermock:powermock-api-mockito:$powerMockVersion" androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
// Connected Tests
androidTestCompile 'org.mockito:mockito-core:1.10.19'
}
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
multiDexEnabled true
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dataBinding {
enabled = true
}
}
apply plugin: 'maven'
apply plugin: 'signing'
def isSnapshot = version.endsWith('-SNAPSHOT')
def ossrhUsername = hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
def ossrhPassword = hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
task setVersion {
// The version will be derived from source
project.version = null
def sdkVersionFile = file('src/main/java/com/facebook/FacebookSdkVersion.java')
sdkVersionFile.eachLine{
def matcher = (it =~ /(?:.*BUILD = \")(.*)(?:\".*)/)
if (matcher.matches()) {
project.version = matcher[0][1]
return
}
}
if (project.version.is('unspecified')) {
throw new GradleScriptException('Version could not be found.', null)
}
}
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Facebook-Android-SDK'
artifactId = 'facebook-android-sdk'
packaging 'aar'
description 'Facebook Android SDK'
url 'https://github.com/facebook/facebook-android-sdk'
scm {
connection 'scm:git#github.com:facebook/facebook-android-sdk.git'
developerConnection 'scm:git#github.com:facebook/facebook-android-sdk.git'
url 'https://github.com/facebook/facebook-android-sdk'
}
licenses {
license {
name 'Facebook Platform License'
url 'https://github.com/facebook/facebook-android-sdk/blob/master/LICENSE.txt'
distribution 'repo'
}
}
developers {
developer {
id 'facebook'
name 'Facebook'
}
}
}
}
}
uploadArchives.dependsOn(setVersion)
signing {
required { !isSnapshot && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// JDK 1.8 is more strict then 1.7. Have JDK 1.8 behave like 1.7 for javadoc generation
if (org.gradle.internal.jvm.Jvm.current().getJavaVersion() == JavaVersion.VERSION_1_8) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
afterEvaluate {
androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
}
Clicking on Upgrade plugin and sync project does not do anything.
I have tried "Invalidate cache and restart" as suggested by various sources but it didn't work. I already have mentioned the latest version of gradle plugin in my project build.gradle.
I have gone through Gradle DSL Method not found: testCompile() but it does not resolve my issue.
What should i do to remove this compile error?
TIA
EDIT 1:
I made the change as suggested by sm4, And this DSL method not found error went off but now it fails to compile with the following error:
def powerMockVersion = '1.6.1'
testCompile "org.powermock:powermock-module-junit4:$powerMockVersion" testCompile "org.powermock:powermock-module-junit4-rule:$powerMockVersion" testCompile "org.powermock:powermock-classloading-xstream:$powerMockVersion" androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
testCompile "org.powermock:powermock-api-mockito:$powerMockVersion" androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
// Connected Tests
androidTestCompile 'org.mockito:mockito-core:1.10.19'
The testCompile is actually a call to a method. Because you have multiple testCompile on one line, it is being treated as a call to a method with many parameters. Such method does not exist.
Keep only one definition per line and it should work:
testCompile "org.powermock:powermock-module-junit4:$powerMockVersion"
testCompile "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
testCompile "org.powermock:powermock-classloading-xstream:$powerMockVersion"
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
testCompile "org.powermock:powermock-api-mockito:$powerMockVersion"
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
After trying the fix mentioned by #sm4 i resolved the initial issue that i mentioned but it created another issue written in EDIT 1 section of question.
I followed this answer and then finally my project got compiled without any error.

Gradle DSL method not found: 'compile()' while using tesseract library

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

Categories

Resources