Using deprecated classes in Android Api 23 - java

I upgraded my com.android.support:support-v4 to 23.2.1 because from Android 6.0 we need to check for and request permissions at runtime.
After I upgraded ,all these error message come up
Error:(48, 31) error: package android.support.v4.view does not exist
android.support.v4.view.PagerAdapter does not exist.
So When I added back old android support jar file to my project libs folder ,
ActivityCompat.requestPermissions cannot be resolved .
compile files('libs/android-support-v4.jar')
I tried several solutions and still not working.Is there any workaround to be able to support all?
Here is my gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
versionCode 117
versionName 'P.5.53.4'
}
signingConfigs {
release {
storeFile file("something.keystore")
storePassword "1234"
keyAlias "something"
keyPassword "1234"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/ASL2.0'
}
configurations {
all*.exclude module: 'servlet-api'
all*.exclude group: 'com.google.gson', module: 'gson'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildTypes {
release {
}
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories{
mavenCentral()
}
}
dependencies {
compile files('libs/aspectjrt.jar')
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.3.jar')
compile files('libs/jackson-core-asl-1.6.2.jar')
compile files('libs/jackson-mapper-asl-1.6.2.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile project(':volley')
compile project(':lib')
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.newrelic.agent.android:android-agent:5.5.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.opencsv:opencsv:3.7'
compile "com.android.support:support-v4:23.2.1"
compile "com.android.support:support-v13:23.1.0"
compile "com.android.support:cardview-v7:23.1.0"
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
//compile files('libs/android-support-v4.jar')
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}

Related

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzc.class

I am making an app in which can edit photos and videos.It also shares edited photos via timeline which is made using Recycler view and Card view.
I am having an error whenever I try to run my app in Android SDK 22 but it is working file in Android SDK 23 and above.
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzc.class
It occurs also I am building apk.
Gradle File for my app
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.practice.android.moments"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [appPackageName: "${applicationId}"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
/* 3)(Creative SDK) Exclude duplicate licenses */
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
//help
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.google.firebase:firebase-invites:11.0.1'
compile 'com.google.firebase:firebase-appindexing:11.0.1'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile ('com.facebook.android:audience-network-sdk:4.11.0'){
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
testCompile 'junit:junit:4.12'}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'}
apply plugin: 'com.google.gms.google-services'
Can any one please help me...
Phone used for testing
Meizu M2 Note OS version 5.1 Lollipop API 22
Redmi Note 3 OS version 6.0.1 Marshmallow API 23
Samsung Note 5 OS version 7.0 Nougat API 24
In my case,this error occurs because I have two different version of google-play-service lib.
I remove one of them,bingo!
Try move this compile
compile 'com.google.android.gms:play-services-auth:11.0.1'

Duplicate files copied in APK META-INF/LICENSE error showing while trying to run test case

Errors log are below:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException: Duplicate files
copied in APK META-INF/LICENSE File1:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.5\7bdb321e86724b16af6134a0fd22fec649eda971\httpmime-4.5.jar
File2:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\xerces\xercesImpl\2.11.0\9bb329db1cfc4e22462c9d6b43a8432f5850e92c\xercesImpl-2.11.0.jar
File3:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.6.0\a0990e2e812ac6639b6ce955c91b13228500476e\jackson-annotations-2.6.0.jar
Dependencies I'm using below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.xyz.testauto"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'junit:junit:4.12'
compile 'io.appium:java-client:3.3.0'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.code.gson:gson:2.5'
compile 'com.testdroid:testdroid-api:2.9'
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'com.google.dagger:dagger:2.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}
}
How I can remove this error ?
You should add this in your build.gradle section
META-INF directory are recognized and interpreted by the Java 2
Platform to configure applications, extensions;
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
Then Clean-Rebuild-Run

SQLiteAssetHelper utils not found

I had another post earlier about my project having a class not found exception for IOUtils. I fixed that, and now my project is crashing again.
Previous post: Android class not found when running on some devices but not on others
Giving me this stack trace now:
java.lang.NoClassDefFoundError: com.readystatesoftware.sqliteasset.Utils
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.copyDatabaseFromAssets(SQLiteAssetHelper.java:455)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.createOrOpenDatabase(SQLiteAssetHelper.java:400)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:176)
at com.testing.data.AppDatabase.<init>(AppDatabase.java:87)
at com.testing.data.AppDatabase.getInstance(AppDatabase.java:70)
It works when I try to run it on my tablet, and it crashes when I try to run it on my phone:
Here is the setup:
Android versions:
`Phone: 4.4.2`
`Tablet: 5.1.1`
SDK Setup:
`compileSdkVersion: 25`
`minSdkVersion: 15`
`targetSdkVersion: 24`
Could there possibly something conflicting? Seems unlikely, but they are both Util classes that are not being found.
Grade as requested:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':volley')
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.maps.android:android-maps-utils:0.3.+'
compile 'com.qozix:tileview:2.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'org.twitter4j:twitter4j-core:4.0.4'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'info.hoang8f:android-segmented:1.0.5'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.testing.base"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
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()
}

android studio Error:Execution failed for task '*****_library:processReleaseManifest'. > Format specifier '20g'

I have a error since several days:
Error:Execution failed for task ':nameproject_library:processReleaseManifest'.
Format specifier '20g'
I have a projet app and a library, i search a lot in stackoverflow and google but all solutions doesn't work for me
build.gradle library:
build.gradle mylibrary :
apply plugin: 'com.android.library'
repositories {
mavenCentral()
jcenter()
maven { url 'http://xxxxxx:8081/nexus/content/groups/public/' }
//maven { url "http://repo1.maven.org/maven2" }
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'android-apt'
def AAVersion = '3.1'
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.google.code.gson:gson:2.3'
compile(
[group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '1.9.9'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.1.1'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.1.2']
)
compile 'org.codehaus.jackson:jackson-core-asl:1.1.0'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'org.springframework.android:spring-android-rest-
template:1.0.1.RELEASE'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:multidex:1.0.0'
compile('org.springframework.security:spring-security-
crypto:3.1.4.RELEASE') {
exclude group: 'org.springframework', module: 'spring-core'
}
//Dependency for Twitter
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/twitter4j-core-4.0.2.jar')
compile files('libs/twitter4j-media-support-3.0.3.jar')
//Dependency for Facebook
//compile 'com.facebook.android:facebook-android-sdk:4.3.0'
// Dependency for Google Sign-In
compile 'com.google.android.gms:play-services-auth:8.4.0'
// Dependency for Location
//compile 'com.google.android.gms:play-services-location:8.4.0'
}
//google plus
apply plugin: 'com.google.gms.google-services'
build.gradle app :
apply plugin: 'com.android.application'
repositories {
mavenCentral()
jcenter()
maven { url 'http://********:8081/nexus/content/groups/public/' }
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'android-apt'
def AAVersion = '3.1'
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "fr.assuristance.presentation"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile project(':filassistance_library')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
With --stacktrace i get
org.gradle.api.GradleException: Could not determine the dependencies of task ':app:mockableAndroidJar'.
any help will be appreciated
I finally resolve the problem
The error Format specifier '20g', coming from the path of project, a folder contains " %"
After that i still have an error: Error:Execution failed for task '::processReleaseResources'. > at index 4
And also in Android SDK i noticed there were a broken sdk tools (i suspect that become broken after i update android studio), so i just delete them and the build now work

app:transformClassesWithJarMergingForDebug’: java.util.zip.ZipException

After I added the Play Services GCM dependency gradle,  it wouldn't build anymore. I get this error during the build
Sync: OK
Make Project: OK
Clean: OK
Run: Error
app:transformClassesWithJarMergingForDebug’:com.android.build.transform.api.TransformException:
java.util.zip.ZipException: duplicate entry:
android/support/annotation/AnimatorRes.class
This issue may be conflict among the libraries. So I did tried excluding support-V4 conflicts from the newly added gradles. Still problem persists.
This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. So i tried cleaning the project, and removing some unused libraries and methods from dependencies in build. Gradle, OR by adding multidex support
Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.widevision.dressnroom"
minSdkVersion 16
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
}
dependencies {
compile files('libs/activeandroid-3.0.jar')
compile files('libs/android-query-full.0.25.10.jar')
compile files('libs/gson-2.2.4.jar')
compile files('libs/okhttp-2.0.0.jar')
compile files('libs/okio-1.0.0.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/joda-time-2.0.jar')
compile files('libs/commons-lang3-3.4.jar')
compile 'com.balysv:material-ripple:1.0.2'
compile files('libs/anjlab-iabv3-current.jar')
compile ('com.google.android.gms:play-services:8.1.0')
{
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.android.support:multidex:1.0.1')
{
exclude group: 'com.android.support', module: 'support-v4'
}
}

Categories

Resources