Is it mandatory to compile my app with api 22 lollipop? - android

My project compiles and runs fine with api 21 and when i try to compile it with api 22 i'm facing many errors from gradle (Error:In <declare-styleable> SherlockSpinner, unable to find attribute android:popupPromptView, and many other errors) and i can't fix them.
So the question is what happens if i let api 22 go and just compile it with api 21, and which devices can't run my app?
UPDATE:
Please take a look at my config and tell me which devices can't run my app
this is a part of my build.gradle config file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.android.gms:play-services-base:6.5.+'
compile project(':chipsLibrary')
compile project(':slidingMenu')
compile project(':listviewanims')
compile project(':switchCompatLibrary')
compile project(':lib_numberpicker')
compile project(':styleddialogslib')
compile project(':doomDatePickerlibrary')
compile project(':swipelistview')
compile project(':actionbarsherlockPullToRefresh')
compile project(':showcaseLib_Untouched_library')
compile project(':cropper')
compile project(':library_androidanims')
compile project(':library_async_45')
compile files('libs/google-api-services-drive-v2-rev123-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/acra-4.5.0.jar')
// Required for Dropbox
compile files('libs/dropbox-android-sdk-1.6.1.jar')
compile files('libs/json_simple-1.1.jar')
compile files('libs/systembartint-1.0.3.jar')
compile files('libs/universal-image-loader-1.9.2 (1).jar')
compile files('libs/volley.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-gson-1.18.0-rc.jar')
compile files('libs/joda-time-2.3.jar')
compile files('libs/itext-4.2.1.jar')
}

Compiling your application by defining particular compile SDK version is only required if you would want to use the features provided by that particular SDK version.
You can definitely compile with lower version and make it compatible for the higher version, but as said above you won't be able to use the new functionalities/features defined by higher version.

Related

Application keeps crashing on start when apk is build using mac

I have an android project, When i build the project using mac application crashes on start. When same is done using Windows system it works fine.
Error log is pasted below.
I have tried all the available solutions here Why would I be getting a NoSuchMethodError at super.onCreate() for registerFragmentLifecycleCallbacks in Android?
java.lang.NoSuchMethodError: No virtual method registerFragmentLifecycleCallbacks(Landroid/support/v4/app/FragmentManager$FragmentLifecycleCallbacks;Z)V in class Landroid/support/v4/app/FragmentManager; or its super classes (declaration of 'android.support.v4.app.FragmentManager' appears in /data/app/android.form.avss.prepaidcard-2/base.apk:classes11.dex)
at android.arch.lifecycle.LifecycleDispatcher$DispatcherActivityCallback.onActivityCreated(LifecycleDispatcher.java:75)
at android.app.Application.dispatchActivityCreated(Application.java:219)
at android.app.Activity.onCreate(Activity.java:1039)
at android.support.v4.app.BaseFragmentActivityDonut.onCreate(BaseFragmentActivityDonut.java:39)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:297)
at android.support.v7.app.AppCompatActivity.o nCreate(AppCompatActivity.java:85)
at android.form.avss.prepaidcard.ihmf_form_fill.ui.Activities.FormBaseActivity.onCreate(FormBaseActivity.java:30)
at android.form.avss.prepaidcard.ihmf_form_fill.ui.Activities.FormFillActivity.onCreate(FormFillActivity.java:147)
Below is the app gradle config. and dependencies i am using.
Client restricted the sdk versions to 23, so i can't update it. I have tried updating compiled version but no luck.
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "android.form.prepaidcard"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
def lifecycle_version = "1.1.1"
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile('com.weiwangcn.betterspinner:library-material:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
//network library
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:retrofit:2.5.0'
compile 'com.squareup.retrofit2:converter-gson:2.5.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.code.gson:gson:2.8.5'
//IHMF dependencies
compile "android.arch.lifecycle:extensions:$lifecycle_version"
compile "android.arch.lifecycle:runtime:$lifecycle_version"
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
// compile 'com.github.gcacace:signature-pad:1.2.1'
// compile 'com.journeyapps:zxing-android-embedded:3.6.0'
// compile 'com.squareup.picasso:picasso:2.5.2'
}
Currently i am clueless as apk installed using windows runs smooth.
i can't decide if its code or build level issue. I always have to push the code to Github in order to debug code in window. Which consumes a lot of times.
Any help would be highly appreciated. Thanks
This response isn't a definite answer, but it's too long to put in a comment.
I have the feeling this is a multi-dex issue with a dependency that is shared amongst modules. It seems to be complaining about support v4 libraries.
In the command window you could run ./gradlew :app:dependencies | grep v4 and see which version don't equal 23.4.0 and then exclude that module from those dependencies.
Or you can take a heavy handed approach and resolve it at the top level and try to force the version:
allprojects {
...
configurations {
all {
resolutionStrategy {
force 'com.android.support:support-v4:23.4.0'
}
}
}
}

All android support libraries must use the same version specification

I dont know where I went wrong, but this keeps me saying
All com.android.support libraries must use the same exact version specification (mixing versions can lead to runtime crashes.) Found versions 24.0.0,23.2.0 Examples include com.android.support:animated-vector-drawable:24.0.0 and com.android.support:cardview-v7:23.2.0
my build.gradle is
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.project"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mani:ThinDownloadManager:1.2.2'
compile 'net.rdrei.android.dirchooser:library:3.2#aar'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.onesignal:OneSignal:3.+#aar'
}
apply plugin: 'com.google.gms.google-services'
It shows error in this line too
compile 'com.android.support:appcompat-v7:23.2.0'
I tried changing compileSdkVersion to 24 too, but nothing seems to work as of now. Actually everything was working fine before I introduced the play services library.
This dependency is using version 24.0.0 of com.android.support:animated-vector-drawable:
compile 'com.google.android.gms:play-services:10.2.0'
which will cause android studio to complain that it could lead to bugs/crashes because versions of all your google libraries don't match.
So you have 2 options: (that I know of off the top of my head)
Change your compileSdkVersion to 24 and change all your support library dependencies to version 24 as well to match the play-services dependencies:
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
Downgrade com.google.android.gms:play-services to 9.4 or 9.2.1 so that it doesn't use version 24 of anything. This still requires a minor change to your support libraries from 23.2.0 to simply 23.0.0
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.google.android.gms:play-services:9.4.0'

Failed to resolve message for support version nowhere referenced in code

I have wasted a full day, and am nowhere close to a solution.
This morning, I decided to add LeakCanary to check leaks in the android app we are developing. I usually work in offline mode as it speeds up builds. After adding it as a dependency, I disabled offline mode.
Within a minute I got an error saying -
Failed to resolve: com.android.support:appcompat-v7:25.0.0
Now currently, we are working with -
compileSdkVersion 23
buildToolsVersion "23.0.3"
and all our android support libraries, both v4 and v7, use 23.1.1
So I thought maybe the LeakCanary library internally uses 25.0.0, so I removed the library from build.gradle.
But the error persisted.
I have tried -
Closing and restarting Android Studio.
Closing and reopening the project in AS.
Invalidating caches and restarting AS.
Clean build.
In effect, my code is exactly similar to what it was yesterday when it was building and running properly, but today it just doesn't seem to go.
What may be the issue?
EDIT
Here is build.gradle -
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
useLibrary 'org.apache.http.legacy'
}
defaultConfig {
applicationId "com.example.pc.vision_test"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
compile 'com.google.http-client:google-http-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-gson:1.20.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.android.support:multidex:1.0.1'
compile 'commons-io:commons-io:2.4'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.github.shazrazdan:Elemento:0.9.7#aar'
compile 'com.afollestad.material-dialogs:core:0.8.6.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.bmarrdev:android-DecoView-charting:v1.2'
compile 'com.vimeo.networking:vimeo-networking:1.0.1'
compile 'com.roomorama:caldroid:3.0.1'
compile 'org.apache:pdfbox-android:1.8.9.0'
compile 'com.android.support:customtabs:23.1.1'
}
apply plugin: 'com.google.gms.google-services'
As per my observation it seems like you haven't updated Android SDK platform and Android Build Tools to version 25.
First of all download and install android sdk platform and build tools from SDK Manager and use the following lines in your build.gradle(module app)
compileSdkVersion 25
buildToolsVersion "25.0.0"
Also update dependencies according to that.
It should work then

TransformException after migrating to Android Studio

I tried to import a working Eclipse Android project to Android Studio. I am working on Mac with the latest version of Android Studio. When I try to build, it keeps on displaying this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/api/client/http/AbstractHttpContent.class
The class generating this issue is in the com.google.http-client:google-http-client-gson:1.20.0 library, in the com.google.api.client.http package. I tried many things with the app.gradle file, such as excluding the com.google.api.client.http group but nothing works. Here is my app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.time2"
minSdkVersion 17
targetSdkVersion 19
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions.encoding = 'ISO-8859-1'
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile 'com.stripe:stripe-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
You should avoid manually adding in libs to your project.
E.g. change
compile files('libs/commons-io-2.4.jar')
compile files('libs/google-api-client-1.18.0-rc.jar')
compile files('libs/google-api-client-android-1.18.0-rc.jar')
compile files('libs/google-http-client-1.18.0-rc.jar')
compile files('libs/google-http-client-android-1.18.0-rc.jar')
compile files('libs/google-oauth-client-1.18.0-rc.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.6.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
to
compile 'commons-io:commons-io:2.4'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
Please verify that these are the correct packages. Let us know what you find after updating?
The library 'com.google.http-client:google-http-client-gson:1.20.0' is composed of the following nine modules:
google-http-client
google-http-client-android
google-http-client-appengine
google-http-client-xml
google-http-client-protobuf
google-http-client-jdo
google-http-client-jackson
google-http-client-jackson2
google-http-client-gson
Some of these e.g. google-http-client is included again in tour dependencies as a jar. Hence the duplicate entry.
Check this link for getting the setup right when using google-http-java-client. It has step by step instruction - Setup Instructions

duplicate entry: com/google/android/gms/common/SupportErrorDialogFragment.class

I am creating project in android studio with multi dex support . I am getting error : java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/SupportErrorDialogFragment.class . I know this issue is for duplicate class. But unable to figure out that which class is getting duplicate and how to fix it. Below are the code of my build.gradle. Please suggest. Thanks.
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.rtpl.create.app.v2"
minSdkVersion 14
targetSdkVersion 19
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':pageIndicator')
compile project(':materialDesign')
compile project(':zxingLib')
compile project(':datetimepickerlibrary')
compile project(':facebookSDK')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/Android_SDK.jar')
compile files('libs/Android_SDK_component.jar')
compile files('libs/crashlytics.jar')
compile files('libs/google-play-services.jar')
compile files('libs/im.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/PayPal_MECL.jar')
compile files('libs/prime-0.6.1.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/socialauth-4.2.jar')
compile files('libs/socialauth-android-2.6.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/universal-image-loader-1.9.1-SNAPSHOT-with-sources.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/gcm.jar')
compile 'com.android.support:multidex:1.0.0'
}
You have conflicting dependencies in your build.gradle, meaning multiple dependencies containing the same classes:
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/gcm.jar')
All of these components are provided by Google Play Services (the first one in the list). So you should only declare Google Play Services once, preferably only the components you're using instead of the full package: See "Selectively compiling APIs into your executable" https://developers.google.com/android/guides/setup
Chances are you won't even need multidex after you simplify your project dependencies.
Also (unrelated), I'm wondering what are these dependencies, if it's the Android framework itself you can remove them:
compile files('libs/Android_SDK.jar')
compile files('libs/Android_SDK_component.jar')

Categories

Resources