Allow insecure protocols, android gradle, aliyun maven - android

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.

Related

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

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' }
}
}

error on updating com.google.gms:google-services version from 4.1.0 to 4.2.0

I am updating the dependencies in my android project. It is a multi-module project with clean architecture.
I have updated all the firebase library versions but whenever I change the com.google.gms:google-services the version from 4.1.0 to 4.2.0 Gradle sync fails with error code 1.
Here is the log of the IDE errors --
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at com.google.android.gms.dependencies.DependencyInspector.registerDependencies(DependencyInspector.java:118)
at com.google.android.gms.dependencies.DependencyInspector.afterResolve(DependencyInspector.java:173)
at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:370)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:352)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
2019-03-30 21:54:24,345 [ thread 70] INFO - System.util.ExternalSystemUtil - External project [/Users/d/C/A] resolution task executed in 4840 ms.
2019-03-30 21:54:24,345 [ thread 70] WARN - ect.sync.idea.ProjectSetUpTask - 1
2019-03-30 21:54:24,345 [ thread 70] INFO - e.project.sync.GradleSyncState - Gradle sync failed: 1
Project level Gradle file --
apply from: 'buildsystem/dependencies.gradle'
apply plugin: 'kotlin'
buildscript {\
ext.kotlin_version = '1.3.21'
repositories {
google()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
//maven { url 'https://dl.bintray.com/android/android-tools' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.+'
classpath "io.realm:realm-gradle-plugin:5.9.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6"
}
}
allprojects {
ext {
androidProductionApplicationId = '****'
androidStagingApplicationId = '****'
androidVersionCode = 264
androidVersionName = "3.0.0-beta"
}
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
apply plugin: "org.sonarqube"
sonarqube {
properties {
property "sonar.host.url", "http://sonar.****.com/"
property "sonar.login", "*****"
property "sonar.projectKey", "android_test"
property "sonar.language", "java"
property "sonar.sources", "src/main"
}
}
App level Gradle file ---
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
repositories {
google() //google's maven repo to use firebase and other google services
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
jcenter()
}
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
signingConfigs {
config {
keyAlias 'MyReleaseKey'
keyPassword '****'
storeFile file('../buildsystem/keystore.release.jks')
storePassword '****'
}
debugconfig {
keyAlias 'MyDebugKey'
keyPassword '****'
storeFile file('../buildsystem/keystore.debug.jks')
storePassword '****'
}
}
compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
buildToolsVersion = globalConfiguration.getAt("androidBuildToolsVersion")
defaultConfig {
applicationId globalConfiguration.getAt("androidProductionApplicationId")
versionCode globalConfiguration.getAt("androidVersionCode")
versionName globalConfiguration.getAt("androidVersionName")
minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
multiDexEnabled true
defaultConfig {
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
vectorDrawables.useSupportLibrary = true
resConfigs "en"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules-presentation.txt'
signingConfig signingConfigs.config
resValue 'bool', 'GHOST_ENABLE', "false"
}
debug {
debuggable true
signingConfig signingConfigs.debugconfig
resValue 'bool', 'GHOST_ENABLE', "true"
}
}
flavorDimensions "default"
productFlavors {
staging {
applicationId globalConfiguration.getAt("androidStagingApplicationId")
resValue 'bool', 'CAN_CHANGE_HOST', "true"
}
production {
applicationId globalConfiguration.getAt("androidProductionApplicationId")
resValue 'bool', 'CAN_CHANGE_HOST', "false"
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
useLibrary 'org.apache.http.legacy'
bundle {
language {
enableSplit = false
}
}
androidExtensions {
experimental = true
}
}
sonarqube {
properties {
property "sonar.java.binaries", "build/intermediates/classes/staging/debug"
}
}
dependencies {
def presentationDependencies = rootProject.ext.presentationDependencies
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation project(':data')
implementation project(':domain')
implementation(presentationDependencies.crashlytics) {
transitive = true;
}
implementation(presentationDependencies.multidex)
api(presentationDependencies.gson)
implementation(presentationDependencies.gcm)
implementation(presentationDependencies.fcm)
implementation(presentationDependencies.jsoup)
implementation(presentationDependencies.mixpanel)
implementation(presentationDependencies.facebook)
implementation(presentationDependencies.branch)
implementation(presentationDependencies.cardview)
implementation(presentationDependencies.recyclerview)
implementation(presentationDependencies.fab2)
implementation(presentationDependencies.design)
// implementation(presentationDependencies.appindexing)
implementation(presentationDependencies.eventbus)
implementation(presentationDependencies.exo)
implementation(presentationDependencies.firebaseauth)
implementation(presentationDependencies.firebasedatabase)
implementation(presentationDependencies.firebaseconfig)
implementation(presentationDependencies.firbaseinvites)
kapt(presentationDependencies.daggerCompiler)
implementation(presentationDependencies.rxAndroid)
implementation(presentationDependencies.rxJava2)
implementation(presentationDependencies.rxAndroid2)
implementation(presentationDependencies.butterKnife)
kapt(presentationDependencies.butterKnifeCompiler)
implementation(presentationDependencies.adapterDelegates)
implementation(presentationDependencies.firebaseCore)
implementation(presentationDependencies.fresco)
implementation(presentationDependencies.frescoAnimatedGif)
implementation(presentationDependencies.volley)
implementation(presentationDependencies.dagger)
implementation(presentationDependencies.isoparser)
implementation(presentationDependencies.kotlin)
implementation(presentationDependencies.lifecycle)
implementation(presentationDependencies.appCompat)
implementation(presentationDependencies.facebookShare)
implementation(presentationDependencies.placeAutoComplete)
implementation(presentationDependencies.googlePlayServiceAuth)
implementation(presentationDependencies.realmAdapters)
implementation(presentationDependencies.socketIo) {
exclude group: 'org.json', module: 'json'
}
implementation(presentationDependencies.lifecycleExtensions)
kapt (presentationDependencies.lifecycleCompiler)
implementation(presentationDependencies.constraintLayout)
}
apply plugin: 'com.google.gms.google-services'

Could not get unknown property 'fabricToolsVersion' for root project 'quickblox-android-sdk-master' of type org.gradle.api.Project

i am getting this error
Error:(7, 0) Could not get unknown property 'fabricToolsVersion' for root project 'quickblox-android-sdk-master' of type org.gradle.api.Project.
Open File
i recently migrated from android 2.3.3 to 3.0.1 the project was working fine. After migrating i got different errors after solving one i get a new error.
can anyone tell me how can i fix this?
here i my gradle.build
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "io.fabric.tools:gradle:$rootProject.fabricToolsVersion"
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs 'libs' }
}
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
flavorDimensions rootProject.dimensionDefault
defaultConfig {
applicationId "com.quickblox.sample.chat"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
productFlavors {
speedDev {
dimension rootProject.dimensionDefault
minSdkVersion 21
}
dev {
dimension rootProject.dimensionDefault
minSdkVersion rootProject.minSdkVersion
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
minifyEnabled false
shrinkResources false
proguardFile 'proguard-rules.pro'
zipAlignEnabled false
}
release {
signingConfig signingConfigs.debug
}
}
signingConfigs {
debug {
storeFile file("../cert/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation (project(":sample-core"))
implementation ("com.quickblox:quickblox-android-sdk-chat:$rootProject.qbSdkVersion")
implementation("com.quickblox:quickblox-android-sdk-content:$rootProject.qbSdkVersion")
implementation "com.github.orangegangsters:swipy:$rootProject.swipyVersion#aar"
implementation "com.github.bumptech.glide:glide:${rootProject.glideVersion}"
implementation (name: 'sticky-list-headers', ext: 'aar')
}
apply from: "../artifacts.gradle"
apply plugin: 'com.google.gms.google-services'
in string:
classpath "io.fabric.tools:gradle:$rootProject.fabricToolsVersion"
of your rootProject/build.gradle file, replace $rootProject.fabricToolsVersion
with
${rootProject.fabricToolsVersion} or 1.25.1.
That should result in:
classpath "io.fabric.tools:gradle:${rootProject.fabricToolsVersion}"
or classpath "io.fabric.tools:gradle:1.25.1".
Or you could create an external property by adding to rootProject/build.gradle parameter ext.fabricToolsVersion = '1.25.1'

Gradle can't see product flavors. How can I add them?

When I try to add a flavor to my project, Gradle simply don't want to sync and even if I sync it I can't see the flavor in Build Variats. What can cause this problem? The project has a few modules, I need to add flavors to the app. My file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
def keystorePropertiesFile = "${rootDir}${File.separator}keystore.properties" as File
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
dexOptions {
javaMaxHeapSize "4g"
}
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId ""
minSdkVersion 21
targetSdkVersion 25
versionCode 9999
versionName "17.2 (9999)"
}
productFlavors {
testFlavor {
applicationId "com.volodymyr.mobiletest"
}
}
def keystoreFilePath = "${System.properties['user.home']}${File.separator}${keystoreProperties['storeFile']}"
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreFilePath)
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
}
debug {
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a'//, 'x86', 'x86_64'
universalApk true
}
}
lintOptions {
lintConfig file("lint.xml")
check "WrongConstant"
abortOnError true
}
}
tasks.whenTaskAdded { task ->
if(task.name.equals("assembleDebug")){
task.dependsOn(lint)
}
}
dependencies {
}
I deleted some info from here, like dependencies, id and so on just to show a structure.
Error:(15, 0) ProductFlavor names cannot start with 'test'
You should use another flavor name
The problem was in that that this gradle file is using only for CI. To change gradle config I needed to improve build file at settings.gradle.

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