Cannot find local aar built through Flutter Module - android

I am trying to add the flutter module as aar dependency on my Android Project. Here is the guide
https://flutter.dev/docs/development/add-to-app/android/project-setup#add-the-flutter-module-as-a-dependency
I am able to generate the local AAR and I can see these steps to be done:
1. Open <host>/app/build.gradle
2. Ensure you have the repositories configured, otherwise add them:
repositories {
maven {
url '/Users/asharma/Documents/Flutter/animation_module/build/host/outputs/repo'
}
maven {
url 'http://download.flutter.io'
}
}
3. Make the host app depend on the Flutter module:
dependencies {
debugImplementation 'com.example.animation_module:flutter_debug:1.0
profileImplementation 'com.example.animation_module:flutter_profile:1.0
releaseImplementation 'com.example.animation_module:flutter_release:1.0
}
4. Add the `profile` build type:
android {
buildTypes {
profile {
initWith debug
}
}
}
In my Android project, I have app module and library module. I want to include this aar in my library module, here is my library module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
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'
}
profile {
initWith debug
}
}
}
dependencies {
debugImplementation 'com.example.animation_module:flutter_debug:1.0'
profileImplementation 'com.example.animation_module:flutter_profile:1.0'
releaseImplementation 'com.example.animation_module:flutter_release:1.0'
}
repositories {
maven {
url '/Users/asharma/Documents/Flutter/animation_module/build/host/outputs/repo'
}
maven {
url 'http://download.flutter.io'
}
}
I have also added mavenLocal() at my project's build.gradle in repository. (Tried with and without it) But dependencies are not resolved.
I get an error:
Could not find com.example.animation_module:flutter_debug:1.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/example/animation_module/flutter_debug/1.0/flutter_debug-1.0.pom
- https://dl.google.com/dl/android/maven2/com/example/animation_module/flutter_debug/1.0/flutter_debug-1.0.jar
- https://jcenter.bintray.com/com/example/animation_module/flutter_debug/1.0/flutter_debug-1.0.pom
- https://jcenter.bintray.com/com/example/animation_module/flutter_debug/1.0/flutter_debug-1.0.jar
Required by:
project :app > project :animation_flutter_sdk
I know dependency is not present on the remote at https://dl.google.com but it is present in my local and gradle should pick it up from my local. Please help me how to build this project.

I have a project with several library modules and an app module. I faced the same issue as I wanted to start the flutter module from one of my library modules.
I solved it by adding
repositories {
maven {
url '../path/to_your/flutter_repo'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
in both app module and library module build.gradle
I didn't need mavenLocal().
I also needed to add
profile {
initWith debug
}
in each modules build.gradle.
This is now how my app module and library module build.gradle looks like:
App module build.gradle:
plugins {
id 'com.android.application'
}
repositories {
maven {
url '../core/webshop/flutter_repo'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
android {
compileSdkVersion toolVersions.compileSdk
defaultConfig {
...
}
signingConfigs {
release {
...
}
}
buildTypes {
release {
...
}
profile {
initWith debug
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Project modules
implementation project('your_lib_module1')
implementation project('your_lib_module2')
...
}
Library module build.gradle, where you want to add flutter module:
apply plugin: 'com.android.library'
repositories {
maven {
url './flutter_repo'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
android {
compileSdkVersion toolVersions.compileSdk
defaultConfig {
...
}
buildTypes {
release {
...
}
profile {
initWith debug
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Project modules
implementation project('your_lib_module3')
// flutter
debugImplementation 'com.example.animation_module:flutter_debug:1.0'
profileImplementation 'com.example.animation_module:flutter_profile:1.0'
releaseImplementation 'com.example.animation_module:flutter_release:1.0'
...
}

I have the same issue and solve it adding in repositories of settings.gradle inside of dependencyResolutionManagement
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven {
url '/yourpath/your_flutter_module/build/host/outputs/repo'
}
maven {
url 'https://storage.googleapis.com/download.flutter.io'
}
}
}

I have the same problem, it is solved by setting the configurations
android {
buildTypes {
release {
....
}
profile {
....
}
debug {
....
}
}
}
configurations {
// Initializes a placeholder for the profileImplementation dependency configuration
profileImplementation {}
}
dependencies {
debugImplementation xxx
// Then it can work
profileImplementation xxx
releaseImplementation xxx
}
Picking a specific build type in a dependency

Related

Failed to resolve in gradle, Unsplash photo picker android studio

I am trying to implement Unsplash API according to this website:
https://unsplash.com/documentation#creating-a-developer-account
But got stuck pretty quickly. I don't know why Gradle refuses to compile so here are some files:
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven { url 'https://jitpack.io' }
}
dependencies {
def nav_version = "2.5.2"
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")
}
}
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (App)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs.kotlin'
id "kotlin-parcelize"
}
android {
compileSdk 33
defaultConfig {
applicationId "com.example.gallery"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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'
}
namespace 'com.example.gallery'
}
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"
// Unsplash
implementation 'com.github.unsplash:unsplash-photopicker-android:1.0.1'
// Kotlin
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
// tests
testImplementation "com.google.truth:truth:1.1.3"
testImplementation "android.arch.core:core-testing:1.1.1"
testImplementation 'org.robolectric:robolectric:4.8'
}
All I try to do is to add those lines (from the GitHub specification):
To integrate UnsplashPhotoPicker into your Android Studio project
using Gradle, specify in your project build.gradle file:
allprojects { repositories {
...
maven { url 'https://jitpack.io' } } } And in your app module build.gradle file, replacing x.y.x by the latest tag:
dependencies { implementation
'com.github.unsplash:unsplash-photopicker-android:x.y.z' }
The problem occured(8 similar problem):
Execution failed for task ':gallery:desugarDebugFileDependencies'.
Could not resolve all files for configuration ':gallery:debugRuntimeClasspath'.
Could not find com.github.unsplash:unsplash-photopicker-android:1.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/unsplash/unsplash-photopicker-android/1.0.1/unsplash-photopicker-android-1.0.1.pom
- https://repo.maven.apache.org/maven2/com/github/unsplash/unsplash-photopicker-android/1.0.1/unsplash-photopicker-android-1.0.1.pom
Required by:
project :gallery
This question was asked Here but got no answer...
Add the
maven { url 'https://jitpack.io' }
in setting.gradle(project level)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
//...
maven { url 'https://jitpack.io' }
}
}

How to generate gRPC code with protobuf on Kotlin for Android client?

I created a gRPC server (hosted by AWS) in nodejs and I can connect to it with a nodejs client implementation from my local machine.
I'm using the com.google.protobuf plugin to auto generate code from my .proto file.
My gradle sync works and the app builds successfully but I can't find the generated code classes.
I'm struggling to find a good implementation example for a Kotlin for Android gRPC client but I followed these articles:
gRPC In Kotlin(Android)
Java Basic Tutorial
My app/src/main/protos/responder.proto file
syntax = "proto3";
option java_package = "protos.grpc";
package responder;
message ConnectionRequest {
int32 userId = 2;
}
message ConnectionResponse {
string response = 1;
}
service ResponderService {
rpc responderConnect (stream ConnectionRequest) returns (stream ConnectionResponse) {};
}
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlin_version = '1.3.72'
protobufPluginVersion = '0.8.6'
grpcVersion = '1.12.0'
protocVersion = '3.2.0'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
def nav_version = "2.2.2"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my app's build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "organisation.responder.two"
minSdkVersion 19
targetSdkVersion 29
versionCode 31
versionName "2.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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"
}
}
dependencies {
...
implementation 'io.grpc:grpc-okhttp:1.30.0'
implementation 'io.grpc:grpc-protobuf-lite:1.30.0'
implementation 'io.grpc:grpc-stub:1.30.0'
implementation 'io.grpc:grpc-core:1.30.0'
compileOnly 'org.apache.tomcat:annotations-api:6.0.53'
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.12.0"
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.30.0"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
javalite {}
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
As I said above, the gradle sync is successful and the project builds successfully. But where is the autogenerated code?
After following this build.gradle file as an example, I managed to generate the grpc code using the gradle protobuf plugin.
Major changes to my app level build.gradle file included:
Adding path to .proto file in sourceSets block under android block.
android {
...
sourceSets {
main {
proto {
srcDir 'src/main/protos' <-- path to .proto file
}
}
}
}
Change the protobuf block in app level build.gradle file
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.12.0"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.30.0"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove javanano
java {
option 'lite'
}
}
task.plugins {
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
After a successful sync and build, the generated code files where located under app/build/generated/source/proto/debug/grpc/protos/grpc/ResponderServiceGrpc.java and app/build/generated/source/proto/debug/java/protos/grpc/Responder.java

Not able to execute testng.xml file from gradle command line

I have created a gradle project with kotlin in android studio for mobile automation And created task in build.gradle While I am executing test from command prompt eg: 'gradle Test' my test is not getting executed(Message is getting printed which is mention on this tasks). When I am executing directly from testng.xml file than scripts is getting executed successfully.
Below sample code for build.gradle
App -> build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.appium.automation"
minSdkVersion 21
targetSdkVersion 28`enter code here`
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'io.appium:java-client:7.0.0'
implementation 'org.assertj:assertj-core:3.12.2'
implementation 'org.testng:testng:6.14.3'
implementation 'org.junit.jupiter:junit-jupiter-api:5.5.0-M1'
implementation 'io.cucumber:cucumber-java8:4.3.1'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'io.cucumber:cucumber-testng:4.3.1'
implementation 'io.cucumber:gherkin:5.1.0'
implementation 'com.aventstack:extentreports:4.0.9'
}
tasks.withType(Test) {
print("Hi")
useTestNG(){
println("Hi2")
suites '/app/testng.xml'
println("Hi3")
}
}
Project -> build.gradle
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I suppose the problem is with test options, try inserting this code to build.gradle in app level.
android {
testOptions {
unitTests.includeAndroidResources = true
unitTests.all {
useJUnitPlatform()
reports {
junitXml.enabled = true
html.enabled = false
}
testLogging {
events "passed", "skipped", "failed"
// to run JUnit 3/4 tests:
testImplementation("junit:junit:4.12")
testRuntime("org.junit.vintage:junit-vintage-engine:5.7.0")
}
}
}
}
This issue was mentioned at: https://github.com/kotest/kotest/issues/622
To execute a concrete test from command line, you can try:
./gradlew test --tests "com.MyTestCkass.myTest"

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 multi module with flavors to maven repository

I've been trying to upload a project to a maven repository unsuccessfully. Here is my project structure :
_root
|_ lib1 (aar)
|_ lib2 (aar)
|_ javalib (jar)
lib1 depends on lib2
lib2 depends on javalib
lib1 and lib2 have two flavors (intg and prod)
Problem is when I launch uploadArchives task I have no pom.xml created.
It seems to be due to my flavors (when I remove flavors it works fine), and I can't figure out how to fix this problem.
I really need to work with flavors ... any help is welcome ;)
here are my build.gradle files :
root :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext.versionName = "$System.properties.version"
configure(subprojects) {
apply plugin: 'maven'
group = 'com.test.build'
version = project.versionName
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8081/content/repositories/test/") {
authentication(userName: "admin", password: "admin123")
}
}
}
}
}
allprojects {
repositories {
jcenter()
}
}
lib1 :
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName project.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prod{}
intg{}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
intgCompile project(path: ':lib2', configuration: 'intgRelease')
prodCompile project(path: ':lib2', configuration: 'prodRelease')
}
lib2 :
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName project.versionName
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
prod{}
intg{}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':javalib')
}
javalib :
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I finally found the answer to my issue :
it is NOT possible, but it might be possible to do it one day :
see documentation about that :
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication
I went through this problem with this solution :
// default publication is production which will be published without env name
publishNonDefault true
defaultPublishConfig "productionRelease"
if (android.productFlavors.size() > 0) {
android.libraryVariants.all { variant ->
// Publish a main artifact, otherwise the maven pom is not generated
if (android.publishNonDefault && variant.name == android.defaultPublishConfig) {
def bundleTask = tasks["bundle${name.capitalize()}"]
artifacts {
archives(bundleTask.archivePath) {
classifier null
builtBy bundleTask
}
}
}
}
}
I am not satisfied with it but it will do the job for now ...
I spend a lot time to discover why my Android project din't upload my modules to maven. The problem is because I didn't set the defaultPublishConfig inside the android {} brackets in the file build.gradle. The snippet below is how I solved my problem. You need set what flavor you wanna publish to Maven (access build variants tab in the Android Studio to see all your flavors name):
android {
...
defaultConfig {
...
defaultPublishConfig "myFlavorDebug"
}
}

Categories

Resources