Problem adding "com.github.persian-calendar:calendar" to an empty android project? - android

What are the correct steps to add "com.github.persian-calendar:calendar:1.2.1" to an empty android project? I have tried different ways including this guide, but Gradle complains about all of them.
Build.gradle (project):
buildscript {
ext { compose_version = '1.2.0' }
}
plugins {
id 'com.android.application' version '7.4.0-alpha10' apply false
id 'com.android.library' version '7.4.0-alpha10' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
allprojects {
repositories {
maven("https://jitpack.io")
}
}
Build.gradle (module):
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.example.trash2'
compileSdk 32
defaultConfig {
applicationId "com.example.trash2"
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.2.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation("com.github.persian-calendar:calendar:1.2.1")
...
}
Error:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'trash2'. ...... Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method maven() for arguments [https://jitpack.io] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

Step 1 :
Use maven { url 'https://jitpack.io' } instead of maven("https://jitpack.io")
Step 2 :
Put maven { url 'https://jitpack.io' } in settings.gradle :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

Related

Allow insecure protocols, android gradle, aliyun maven

When I download a new android project from git, I met this problem:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/repositories/jcenter)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.3.3/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
In addition, I've viewed this blog without an answer. Because I have found no 'aliyun' maven usage in the project by 'Search Everywhere' and 'Find In Path' .You can see my problem in the follow picture.
details
search res
project root path
settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jcenter.bintray.com" }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "viewer"
include ':app', ':daogenerator'
project root path
build.gradle
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'com.google.gms.google-services' version '4.3.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module app
build.gradle
apply plugin: 'com.android.application'
if (file('google-services.json').exists()) {
apply plugin: 'com.google.gms.google-services'
// apply plugin: 'io.fabric'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
ndkVersion '23.1.7779620'
flavorDimensions "distribute"
productFlavors {
appCenter {
dimension "distribute"
}
googlePlay {
dimension "distribute"
}
}
defaultConfig {
applicationId "com.xjs.viewer"
minSdkVersion 23
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
versionCode 111
versionName "1.9.4.2"
vectorDrawables.useSupportLibrary = true
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
"es", "ja", "ko", "fr", "de", "th"
testOptions.unitTests.includeAndroidResources = true
ndk {
moduleName "native-lib"
abiFilters "armeabi-v7a" , "arm64-v8a", "x86", "x86_64"
}
externalNativeBuild {
cmake {
cppFlags ''
}
}
}
lint {
disable 'MissingTranslation'
abortOnError true
checkReleaseBuilds true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.viewer.fileprovider"'
}
debug {
applicationIdSuffix ".debug"
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.viewer.debug.fileprovider"'
}
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
}
}
sourceSets {
main {
java.srcDirs += 'src/main/java-gen'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildFeatures {
viewBinding true
}
}
task copyNotice(type: Copy) {
from '../NOTICE.html'
into './src/main/assets'
finalizedBy ":daogenerator:executeDaoGenerator"
}
tasks.withType(JavaCompile) {
task -> task.dependsOn copyNotice
}
clean {
delete file('src/main/assets/NOTICE.html').absolutePath
}
dependencies {
......
}
configurations.all {
resolutionStrategy {
.......
}
}
Please help me./(愒o愒)/~~
updated my gradle version to 7.3.3.
I finally solved it by updata Android Studio to newest version....
I don't know what happend definitely.

Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from

I updated my targetSDKVersion and compileSdkVersion from 30 to 32, but now when I'm running the app, app:KaptDebugKotlin is failing. I used the debug-option to get more details and I'm receiving this error:
My build.gradle (module) file:
android {
compileSdkVersion 32
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "com.eschbachit.petrolinemobile"
minSdkVersion 22
targetSdkVersion 32
versionCode 1628
versionName "2.3.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
dataBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral()
}
And this is my build.gradle (project) file:
buildscript {
ext.kotlin_version = '1.4.20-M1'
repositories {
jcenter()
google()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
ext {
compiler_version = '3.1.3'
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$compiler_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
My distributionURL is: distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-bin.zip
I tried different solutions from other answers but nothing worked for me
EDIT: This answer https://stackoverflow.com/a/69250502/15352563 solved my issue! If anybody have the same issue, this might help

Failed to resolve dependency android

I am trying to add exoplayer dependency version 2.12.2 and getting the below error
Failed to resolve: com.google.android.exoplayer:exoplayer:2.12.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
Gradle version 7.2
Top level build gradle
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level build gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ext.line"
minSdk 23
targetSdk 32
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'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "com.google.android.exoplayer:exoplayer:2.12.2"
}
And the settings gradle file
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My Application"
include ':app'
Try adding maven {url 'https://jitpack.io'} in settings.gradle.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Solved by using jcenter()
Applicable to exoplayer versions below 2.13.3
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}

Handling release.keystore while uploading android library to jitpack

I was trying to publish a snapshot of a branch as a jitpack library, but during the build (initiated by jitpack) this error comes up in the logs when I click on get in the jitpack website.
What went wrong:
Execution failed for task ':openmrs-client:validateSigningRelease'.
Keystore file '/home/jitpack/build/release.keystore' not found for signing config 'release'.
I saw the build.gradle file as far as I can understand the release build depends upon the environment variables in travis. then how do I upload this snapshot to jitpack library?
I have seen most of the tutorials but none of them covers up this case :(
settings.gradle
include ':openmrs-android-sdk'
include ':openmrs-client'
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'
ext.safeargs_version = '2.3.0'
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$safeargs_version"
classpath "com.hiya:jacoco-android:0.2"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
app level build.gradle
buildscript {
repositories {
jcenter()
maven {url 'https://oss.sonatype.org/content/repositories/snapshots'}
}
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
plugins {
id 'com.android.application'
id 'com.github.triplet.play' version '2.2.1'
id 'kotlin-android'
id 'kotlin-android-extensions'
// TODO AC-861
//id 'jacoco-android'
id 'com.hiya.jacoco-android'
}
apply from: './versions.gradle'
apply plugin: "androidx.navigation.safeargs"
def version = versions.appVersion
def GOOGLE_PLACE_API_KEY = System.getenv('GOOGLE_PLACE_API_KEY') ?: "YOUR_API_KEY"
android {
compileSdkVersion versions.compileSdk
def travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER")
def buildNumber = (travisBuildNumber) ? (travisBuildNumber as int) : 1
def applicationVersion = version
def travisTag = System.getenv("TRAVIS_TAG")
def buildVersionName = (travisTag) ? travisTag : applicationVersion + "-debug." + buildNumber
defaultConfig {
applicationId "org.openmrs.mobile"
versionName buildVersionName
versionCode buildNumber
multiDexEnabled true
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
testApplicationId "org.openmrs.mobile.test"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
manifestPlaceholders = [
GOOGLE_PLACE_API_KEY: GOOGLE_PLACE_API_KEY
]
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
signingConfigs {
release {
storeFile rootProject.file('release.keystore')
storePassword System.getenv("KEYSTORE_PASSWORD")
keyAlias System.getenv("KEYSTORE_ALIAS_NAME")
keyPassword System.getenv("KEYSTORE_ALIAS_PASS")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
debug {
testCoverageEnabled true
}
}
lintOptions {
warning 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/rxjava.properties'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
returnDefaultValues = true
includeAndroidResources = true
}
}
buildFeatures {
viewBinding = true
}
}
repositories {
maven { url 'http://yanzm.github.io/MaterialTabHost/repository' }
mavenCentral()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
// Android sdk library dependency
implementation project(path: ':openmrs-android-sdk')
//more dependencies....
}
library module build.gradle
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'maven-publish'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 17
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dependencies {
//.. some dependencies..
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId = 'com.openmrs.AndroidSDK'
artifactId = 'final'
version = '1.0.0'
}
debug(MavenPublication) {
from components.debug
groupId = 'com.openmrs.AndroidSDK'
artifactId = 'final-debug'
version = '1.0.0'
}
}
}
}
}

Proguard doesn't build project with duplicate classes

I have one flavor for specific device. For this device I have .jar file which have custom android sdk(for this device. It contains some custom class which I have to use). And it works fine until I start use proguard. When I build project with proguard I receive this:
...
Note: there were 1504 duplicate class definitions.
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:proguardAppProguard'.
> java.io.IOException: Please correct the above warnings first.
I found that adding a string:
-ignorewarnings
to proguard-android.txt fixes this problem, but it looks like bad solution. Did somebody face this(or similar) problem?
Edit
build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'android-apt'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
}
def computeVersionName() {
return "r_1.0"
}
android {
compileSdkVersion 23
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.app"
multiDexEnabled true
String buildSuf = System.getenv("BUILD_NUMBER");
ext.defaultName = project.archivesBaseName;
if (buildSuf != null) {
def vers = Integer.parseInt(buildSuf)
println "VERCODE = ${vers}"
versionCode vers
} else {
versionCode 1000
}
minSdkVersion 16
targetSdkVersion 21
}
productFlavors {
app {
applicationId "com.app"
versionName computeVersionName()
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
disable 'InvalidPackage'
}
signingConfigs {
...
customerProgurd {
storeFile file('../keys/debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
...
}
buildTypes {
...
customerProguard {
debuggable false
jniDebuggable false
minifyEnabled true
proguardFiles rootProject.file('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.customerProgurd
}
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
...
app files('libs/classes.jar') // it's custom sdk
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
...
}

Categories

Resources