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'
}
}
}
}
Related
I am trying to implement firebase into my project. But when the program run for the first time it shows this error :
java.lang.NoSuchMethodError: No static method isDeviceProtectedStorage(Landroid/content/Context;)Z in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.example.project-1/base.apk)
and below is my gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.project"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildToolsVersion "25.0.1"
sourceSets {
main {
aidl.srcDirs = ['src/aidl']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'src/main/jnilibs', include: ['.jar','.so'])
compile files('libs/gcm.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/gson-2.7.jar')
compile files('libs/httpclientandroidlib-1.2.0.jar')
compile files('libs/logging-interceptor-3.0.1.jar')
compile files('libs/okhttp-3.0.1.jar')
compile files('libs/okhttp-urlconnection-3.0.1.jar')
compile files('libs/okio-1.10.0.jar')
compile files('libs/rollbar-android-0.1.3.jar')
compile files('libs/sherlocknavigationdrawer-1.0.jar')
compile files('libs/v7compat.jar')
compile files('libs/mpChart.jar')
compile files('libs/picasso-2.5.2.jar')
compile project(':actionbarsherlock')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
}
apply plugin: 'com.google.gms.google-services'
I've read somewhere else it may be due to lower version of v4 support library. so I had it changed to higher api level, but the problem still persist. Any solution to solve this problem??
Reason of this exception is AppCompatActivity derived from the v7 library. so we should provide proper library based on your gradle and SDK.
You should update the dependency Libraries also.
Right click on the project in the project structure -> select Open module settings and select dependencies tab -> Library module-> then type which library you want add to the project. It shows the latest libraries based on your gradle updated version, then select latest one and remove the existing one.
For example In my project "appcompat-v7" version was 23.4.0 then I was changed to 27.0.2 which is latest one
Or try to use
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
I tried for many hours to find the solution but could not find. My problem is that when I build my Gradle I get two errors. I tried to look at this solution
Dependency conflict error in my Android app which has Android Tests but could still not solve the problem.
Error:Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.10) and test app (4.12) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Here's my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "voice.com.topsalai"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.3-
alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.android.support:support-annotations:26.0.0-alpha1'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
How can I solve this?
dont use alpha..or beta.. just use the latest stable one..then please dont mix your android support version.. use same version for all android support
example
compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:cardview-v7:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:support-annotations:25.3.1"
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:support-v13:25.3.1"
please remove this two dependency
testCompile 'com.android.support:support-annotations:26.0.0-alpha1'
androidTestCompile 'com.android.support:support-annotations:26.0.0-alpha1
I found the solution. By upgrading compileSdkVersion to
compileSdkVersion 25
And then Instead of this
compile 'com.android.support:appcompat-v7:23.1.1'
Only by updating appcompat-v7:23.1.1 did not solve it. I needed theese 3 lines of code.
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
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
I am new in Android. i am currently working in android app and when i try to run the app this error occurs.
I have researched but cant solve this error.
error
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
multiDexEnabled true
applicationId "com.tutorialsbuzz.androidfacebook"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.android.gms:play-services:7.5.0'
}
thankyou in advance
In my case, it's because of the
compile 'com.facebook.android:audience-network-sdk:4.+'
I change it to this:
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
No more problem!
The reason behind that may be you have include two different versions for gms. Also if you have included the complete package then there is no need to include the second 'compile 'com.google.android.gms:play-services:7.5.0'' If you need only auth services from google then dont include the complete package it ll exceed 65k methods and duplicacy chances will be there.
Include this
compile 'com.google.android.gms:play-services-auth:9.4.0'
and from your code remove
compile 'com.google.android.gms:play-services-auth:9.2.1' compile
'com.google.android.gms:play-services:7.5.0'
Execute it and let me know once.
If you are using Firebase, you should read my solution. In my case I developed a new app. This new app has ads, so I put compile 'com.google.firebase:firebase-ads:11.0.4' BEFORE compile 'com.google.firebase:firebase-core:11.0.4'.
But either you have to put everything AFTER firebase-core or it's about the version number 11.0.4 that have to be the same on all firebase modules you are using.
Excluding com.google.android.gms from the offending package worked to build the project for me, but unfortunately the app would crash during initialization. The solution for me was to upgrade all firebase dependencies from 11.6.0 to 11.8.0, ie:
- compile "com.google.android.gms:play-services-base:11.6.0"
- compile "com.google.firebase:firebase-core:11.6.0"
- compile "com.google.firebase:firebase-messaging:11.6.0"
- compile "com.google.firebase:firebase-analytics:11.6.0"
- compile "com.google.firebase:firebase-ads:11.6.0"
+ compile "com.google.android.gms:play-services-base:11.8.0"
+ compile "com.google.firebase:firebase-core:11.8.0"
+ compile "com.google.firebase:firebase-messaging:11.8.0"
+ compile "com.google.firebase:firebase-analytics:11.8.0"
+ compile "com.google.firebase:firebase-ads:11.8.0"
The problem was only presenting itself when adding firebase-ads but this fixed it.
Please be sure that you are using identical versions of com.google.gms.
You can run the next command from the project root dir to find out which versions are used:
./gradlew :<subproject>:dependencies
Usually it is something like this:
./gradlew :app:dependencies
After analyzing you are able to set the same versions or exclude group from some modules or expose a version
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.