Proguard doesn't build project with duplicate classes - android

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

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.

running into android studio issue Could not GET exoplayer

I have been running into this error while trying to build my app and do not know how to resolve it, when I toggle Gradle offline mode, the error disappears but other dependency requires it to be turned off.
Could not GET 'https://google.bintray.com/exoplayer/com/google/gms/google-services/4.3.4/google-services-4.3.4.pom'. Received status code 502 from server: Bad Gateway
Disable Gradle 'offline mode' and sync project
This is my build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my second buid.gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.9'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
android {
signingConfigs {
release {
storeFile file('C:\\Users\\Osas Divine\\Desktop\\sckoolite\\unilorin-sckoolboy.jks')
storePassword '123456/'
keyAlias 'key0'
keyPassword '123456/'
}
}
compileSdkVersion 29
defaultConfig {
applicationId "com.sckoolboy.unilorin"
manifestPlaceholders = [onesignal_app_id: "d0989000-9ff3-4214-a42b-ed8f5a123456",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
minSdkVersion 19
targetSdkVersion 29
versionCode 11020
versionName '5.2.2'
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
archivesBaseName = "Sckoolboy"
useLibrary 'org.apache.http.legacy'
signingConfig signingConfigs.release
}
dexOptions {
jumboMode true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
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
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.vivchar:ViewPagerIndicator:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.7.2'
implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.1'
..........
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
// google maps library ------------------------------------------------------------------------
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation('com.google.android.libraries.places:places:1.0.0') {
exclude module: 'glide'
}
}
apply plugin: 'com.google.gms.google-services'

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.

Categories

Resources