How to "compileOnly" my android repository from github - android

I'm implementing my android-module from github using jitpack,
and i want to do compileOnly instead of implementation
but when I use the code compileOnly it shows me
that the complieOnly not supported
I'm creating an application to read plugins
all application and plugins depends on a library I have created
the plugin well have a classes that extends a class on the library
and the application should read those classes and invoke methods on them
as you know the application SHOULD contains the library classes
and the plugin SHOULDN'T, else we'll face a doublecated classes exception or/and class cast exception
I worked on it and it worked perfectly while the application and
the plugins all compiled the library using an aar file of it
but when i decied to move on to github implementation
it worked for the application but not for the plugin
and the issue is i can't tell gradle to do compileOnly to the library
plugin's module build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
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 = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
compileOnly 'com.github.LSaferSE:Services-Android:master'//<--- here is the problem
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
}
plugin's project build.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
expecting a build success but faced :
ERROR: Android dependency 'com.github.LSaferSE:Services-Android:master' is set to compileOnly/provided which is not supported
one more thing, I tried using api instead but I'm not sure what's the diffrent from implementation, but I'm sure it'll pack library classes in the plugin's apk, so please tell me if you know it'll not effect while loading the apk using DexClassLoader (fyi it'll effect using implementation)

Related

Kotlin library was complied with a newer Kotlin compiler and can't be read

Hello I tried to run Kotlin file on Android Studio (version 4.1) and I got an error:
Kotlin library {0} was compiled with a newer Kotlin compiler and can't be read. Please update Kotlin plugin.
Even I got this error I'm able to run kotlin files but Ide don't gives me tips when I use kotlin functions and methods are marked by red colour. Kotlin version in gradle is 1.6.0, if I'm return to older version I can see tips about method names and red colour is not showed.
Gradle build(app):
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.kotlin_udemy4"
minSdkVersion 26
targetSdkVersion 31
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'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Gradle build:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.6.0"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Does anyon know how to resolve that issue ?
Besides Kotlin version 1.6.21 ...
That version of Android Studio appears rather outdated; eg. the current version "Chipmunk" uses:
com.android.tools.build:gradle:7.2.1
jcenter() should be replaced with mavenCentral().
And also, use JavaVersion.VERSION_11.
I have similar problem. To solve this, I do the following things:
I try to Rebuild the project, then this error log appear:
The minCompileSdk (32) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-31).
Dependency: androidx.appcompat:appcompat-resources:1.5.0.
AAR metadata file: C:\Users..........
Lower androidx.appcompat:appcompat version to 1.4.0, and then sync gradle. That's it.
Maybe you can try this way.
Next to isssue popup i selected "Details" link and there was information about expected version. Probably because I'm using older Android studio I got the problem. I updated Kotlin in gradle build to: 1.4.32 according to message.

Some Kotlin libraries attached to this project were read by a newer Kotlin compiler and can't be read. Please update Kotlin Plugin

I am facing an error:
Some Kotlin libraries attached to this project were read by a newer Kotlin compiler and can't be read. Please update Kotlin Plugin
I just created an application and started facing this error:
The Kotlin plugin shows the following:
I tried to change ext.kotlin_version:
My build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.32"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My build.gradle(app):
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion '30.0.1'
defaultConfig {
applicationId "com.yousufjamil.myj"
minSdkVersion 16
targetSdkVersion 31
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'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
I would appreciate any help. Thank You!
You need to update almost everything, I believe.
currently for Gradle we have
com.android.tools.build:gradle:7.2.1
coming to Kotlin, the current version is 1.6.21
repository jcenter() is deprecated and has been replaced by mavenCentral()
If you try to use jcenter() it will give a warning
JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere
Also, check if there are any updates available for Android Studio.
Earlier I had the same error on Android Studio. If by changing the kotlin-version and gradle-version in the build.gradle file does not fixes the error. It might be because you have an older version and need to update the Android Studio [File -> Settings -> Appearance & Behavior -> System Settings -> Updates -> ' then Change to the latest stable version']. Later during the installation process, you would see the option to upgrade the gradle where you can choose the latest version. It worked for me. Hope it helps!
1- update the android studio by clicking the tab named help and then click "check for update" and then let the android studio be updated.
2 - restart the android studio if the error is resolved then it's well and good if not, then click on the tab "New", click on "New project" and then select project, and check the box highlighted here in the below picture.
click here to see the image
this worked for me
update android studio to the lastest version
only need to del these
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

Failed to resolve: org.jitsi.react:jitsi-meet-sdk:3.+

I tried changing the compilesdk and mindsdk versions as told here. I read all the other posts regarding the same but none worked so far. I have looked at the previous answers ans1 and ans2 . They didn't helped.
When I try to run the project it throws multplie errors. I think the main problem is because of this one
Could not find any matches for org.jitsi.react:jitsi-meet-sdk:3.+ as no versions of org.jitsi.react:jitsi-meet-sdk are available.
build.gradle(My application)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(app)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 30
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-common-ktx:20.0.0'
implementation 'com.google.firebase:firebase-firestore:24.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation ('org.jitsi.react:jitsi-meet-sdk:3.+') { transitive = true }
}
Any help is appreciated.
I find a workaround for this. You've to paste the maven URL into settings.gradle file. Some other user was facing a problem similar to this here . I did the same and it's working fine.
+1 / Failed to resolve: org.jitsi.react:jitsi-meet-sdk:3.+
5 min
I had added the maven dependency in the wrong place. It goes in the project gradle, under allprojects->repositories.
new fail
A problem occurred evaluating root project 'My Application'.
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
For me the problem was with the SDK version
I replaced this line
implementation ('org.jitsi.react:jitsi-meet-sdk:+') { transitive = true }
with this line
implementation ('org.jitsi.react:jitsi-meet-sdk:5.1.0') { transitive = true }
If you are using React-Native < 0.60, you should use a version < 2.0.0.
For versions higher than 2.0.0, you need to add the following piece of code in your metro.config.js file to avoid conflicts between react-native-jitsi-meet and react-native in metro bundler.
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/ios/Pods/JitsiMeetSDK/Frameworks/JitsiMeet.framework/assets/node_modules/react-native/.*/,
]),
},
};
ref: https://github.com/skrafft/react-native-jitsi-meet

Failed to calculate the value of task ':app:mergeLibDexDebug' property 'numberOfBuckets'. Expected minSdkVersion >= 21 but found 1

Have a good day everyone. I am starting my studies in Kotlin using Android Studio in its version 4.2.2. I have created a project from 0 using the IDE itself and I get the error:
Execution failed for task ':app:mergeLibDexDebug'
Failed to calculate the value of task ':app:mergeLibDexDebug' property
'numberOfBuckets'.
Expected minSdkVersion >= 21 but found 1
I was looking in other publications that spoke of compilation problems mainly due to incompatibilities in the dependencies included in the project, but none spoke exactly about the error that I am presenting...
The gradle module has the default code when creating the application which is the following:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.nueva"
minSdkVersion 28
targetSdkVersion 30
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'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
The gradle project also has the default configuration that it brings when the application is created:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.20"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
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()
mavenCentral()
// jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I don't have any additional implementation either in MainActivity.kt or another project file. If anyone has been through this error and fixed it please I would really appreciate if you would share with me how to eliminate this error. Maybe the solution is simple, but as I said before I am new to the world of Kotlin and I would like very much in the future to be able to be involved in the world of developing applications for smartphones. Without further ado, thank you very much in advance to anyone who can help
Can you make sure test on a Device >= API Level 21 ? Also check from Settings for New Projects to be selected Android 11.0 (R) or Android 9.0 Pie (check also these versions are installed in sdk manager)

How to build and use Mosby library?

I try to add Mosby library to my pet project, but i cannot understand how to include it to project?
I try to add mosby by add as module-> add as Gradle project, but it not compile.
please, can you link me some tutorial how to add projects (source) into my project and how to use it then (i mean a access to libs classes from my code)?
Thank you!
P.S. Project stores at K:\PetProject. Mosby at: K:\mosby.
settings.gradle (of my project):
include ':app', ':mvp', ':sample-dagger2-rx', ':sample', ':mvp-common', ':viewstate', ':sample-kotlin', ':sample-flow', ':testing', ':sample-mail', ':sample-dagger1'
build.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:2.0.0-beta7'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle at myproject\app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "net.simplevolk.mafiagm"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/java/2'] } }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
}
Mosby should be added to your project by adding the following to the dependencies section in your build.gradle at myproject\app rather than as a module as how you did it.
compile 'com.hannesdorfmann.mosby:mvp:2.0.1'
compile 'com.hannesdorfmann.mosby:viewstate:2.0.1' // optional viewstate feature
As for a tutorial for using Mosby, the url at the top of the Mosby github page links to information about the library including a tutorial about how to use it. I found the walk through of the sample-mail app at http://hannesdorfmann.com/mosby/first-app/ helpful when I started using Mosby.

Categories

Resources